主席树模板题
本来想用treap写
但是看到强制在线就放弃了
还是有点不熟,多练
1 #include<algorithm> 2 #include<iostream> 3 #include<cstdlib> 4 #include<cstring> 5 #include<cstdio> 6 #include<string> 7 #include<cmath> 8 #include<ctime> 9 #include<queue> 10 #include<stack> 11 #include<map> 12 #include<set> 13 #define rre(i,r,l) for(int i=(r);i>=(l);i--) 14 #define re(i,l,r) for(int i=(l);i<=(r);i++) 15 #define Clear(a,b) memset(a,b,sizeof(a)) 16 #define inout(x) printf("%d",(x)) 17 #define douin(x) scanf("%lf",&x) 18 #define strin(x) scanf("%s",(x)) 19 #define LLin(x) scanf("%lld",&x) 20 #define op operator 21 #define CSC main 22 typedef unsigned long long ULL; 23 typedef const int cint; 24 typedef long long LL; 25 using namespace std; 26 void inin(int &ret) 27 { 28 ret=0;int f=0;char ch=getchar(); 29 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=1;ch=getchar();} 30 while(ch>=‘0‘&&ch<=‘9‘)ret*=10,ret+=ch-‘0‘,ch=getchar(); 31 ret=f?-ret:ret; 32 } 33 int CSC() 34 { 35 freopen("in.in","w",stdout); 36 srand(time(0)); 37 int n,m; 38 n=100000,m=100000; 39 cout<<n<<" "<<m<<"\n";int Max=0; 40 re(i,1,n) 41 { 42 int l=rand()%100000+1; 43 int r=rand()%100000+1; 44 if(l>r)swap(l,r); 45 int k=rand()%10000000+1; 46 printf("%d %d %d\n",l,r,k); 47 Max=max(max(l,r),Max); 48 } 49 re(i,1,m) 50 { 51 int l=rand()%100000+1; 52 int r=rand()%100000+1; 53 printf("%d %d %d %d\n",rand()%Max+1,l,r,n); 54 } 55 return 0; 56 }
原文:http://www.cnblogs.com/HugeGun/p/5180626.html