标签:each nbsp algo accept content group 思路 about class
Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 2297 Accepted Submission(s): 687
unsigned x = A, y = B, z = C;
unsigned rng61() {
unsigned t;
x ^= x << 16;
x ^= x >> 5;
x ^= x << 1;
t = x;
x = y;
y = z;
z = t ^ x ^ y;
return z;
}
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<algorithm> 5 using namespace std; 6 const int MAXN=1e7+5; 7 unsigned n, m; 8 unsigned rat[MAXN], b[MAXN],p[MAXN], a[MAXN]; 9 unsigned x,y,z; 10 unsigned rng61() { 11 unsigned t; 12 x ^= x << 16; 13 x ^= x >> 5; 14 x ^= x << 1; 15 t = x; 16 x = y; 17 y = z; 18 z = t ^ x ^ y; 19 return z; 20 } 21 bool cmp(int s, int t) 22 { 23 return b[s]<b[t]; 24 } 25 int main() 26 { 27 int k=0; 28 while(~scanf("%d %d %u %u %u", &n, &m, &x, &y, &z)) 29 { 30 for(int i=0;i<m;i++){ 31 p[i]=i; 32 scanf("%d", b+i); 33 } 34 35 for(int i=0;i<n;i++) 36 rat[i]=rng61(); 37 sort(p, p+m,cmp); 38 b[p[m]=m]=n; 39 for(int i=m-1;i>=0;i--){ 40 if(b[p[i]]==b[p[i+1]]){ 41 a[p[i]]=a[p[i+1]]; 42 //continue; 43 } 44 nth_element(rat, rat+b[p[i]], rat+b[p[i+1]]); 45 a[p[i]]=rat[b[p[i]]]; 46 } 47 printf("Case #%d:", ++k); 48 for(int i=0;i<m;i++) 49 printf(" %u", a[i]); 50 printf("\n"); 51 } 52 }
HDU 6040 Hints of sd0061 —— 2017 Multi-University Training 1
标签:each nbsp algo accept content group 思路 about class
原文地址:http://www.cnblogs.com/MasterSpark/p/7265938.html