[Exam reflection] 0224 provincial election simulation 30: panic

Cancer of the large collection.

$ T1 $ basic points but no violence is a collection of two positive solutions to violence. . Then simply write only one of the more simple a word that no one point. .

$ T2 $ violent write positive solutions do not know what things. But i open my array is too large, the machine but nothing to pay up $ CE $ a. (I did not put the call through the sieve Du teach hash table to be deleted is not the $ CE $)

However, only $ 10 $ points. Constant ugly. All the arrays are reduced to $ \ frac {1} {10} $ $ 20 $ have divided. weird.

$ T3 $ card is a malignant tumor often interactive questions, obviously complexity $ O (n \ log \ n) $ measured have to but because the so-called card to $ O (10n) $.

However, I have no idea, after all, only to write $ O (n ^ 2) $ of positive solutions to optimize the idea is good. But because cancer card so it is still often delayed my one afternoon.

I do not know why and did not stay for more time to change the title, so Gou over $ T3 $ then $ T1 $ wrote the score violence is over.

Ah ah ah my video lesson ah. . .

 

T1: despite starting storms, sit back

Effect: one for $ $ $ k $ n-bit binary numbers, the XOR seeking twenty-two and cubic. $ Nk \ le 2 \ times 10 ^ 6 $

For $ k \ geq 128 $ direct violence, the bitset $ $ handwriting pressure level, $ 2 ^ {64} $ hex good results.

For $ k <128 $, bit by bit to consider contributions. Cube is found to be repeated three choices, if the three different numbers in the two values ​​are $ 1 or $ then produce the product of the contribution of the three.

So with $ bitset $ on the pressure on which there is a number which is a number which is 0, and then with a fine.

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define ull unsigned long long
 4 #define mod 998244353
 5 unsigned int seed;int n,k,x,ans,bit[1<<16];ull jz=((1ull<<63)%mod<<1)%mod,pw[555];
 6 vector<ull>b[20005],r,c[20005];
 7 ull get01(){
 8    seed^=seed<<13;
 9    seed^=seed>>17;
10    seed^=seed<<5;
11    return seed&1;
12 }
13 int cnt(ull s){return bit[s&65535]+bit[s>>16&65535]+bit[s>>32&65535]+bit[s>>48];}
14 int main(){
15     cin>>n>>k>>x>>seed;
16     if(k>=128){
17         for(int i=1;i<=n;++i)b[i].resize((k>>6)+1);r.resize((k>>6)+1);
18         for(int i=1;i<=n;++i)for(int j=0;j<k;++j)b[i][j>>6]|=get01()<<(j&63);
19         const int K=k-1>>6;
20         for(int i=1;i<=n;++i)for(int j=i+1;j<=n;++j){
21             for(int x=0;x<=K;++x)r[x]=(b[i][x]^b[j][x])%mod;
22             ull tot=0,p=1;
23             for(int x=0;x<=K;++x)tot=(tot+p*r[x])%mod,p=p*jz%mod;
24             ans=(ans+tot*tot%mod*tot)%mod;
25         }cout<<ans<<endl;return 0;
26     }const int N=n-1>>6; r.resize(N+1);
27     for(int i=0;i<k;++i)b[i].resize(N+1),c[i].resize(N+1);
28     for(int i=0;i<n;++i)for(int j=0;j<k;++j)b[j][i>>6]|=get01()<<(i&63),c[j][i>>6]|=b[j][i>>6]&(1ull<<(i&63))^(1ull<<(i&63));
29     pw[0]=1;
30     for(int i=1;i<555;++i)pw[i]=(pw[i-1]+pw[i-1])%mod;
31     for(int i=1;i<1<<16;++i)bit[i]=bit[i>>1]+(i&1);
32     for(int i=0;i<k;++i)for(int j=i;j<k;++j)for(int x=j;x<k;++x){
33         int _000=0,_001=0,_010=0,_011=0,_100=0,_101=0,_110=0,_111=0;
34         for(int y=0;y<=N;++y)
35             _000+=cnt(c[i][y]&c[j][y]&c[x][y]),
36             _001+=cnt(c[i][y]&c[j][y]&b[x][y]),
37             _010+=cnt(c[i][y]&b[j][y]&c[x][y]),
38             _011+=cnt(c[i][y]&b[j][y]&b[x][y]),
39             _100+=cnt(b[i][y]&c[j][y]&c[x][y]),
40             _101+=cnt(b[i][y]&c[j][y]&b[x][y]),
41             _110+=cnt(b[i][y]&b[j][y]&c[x][y]),
42             _111+=cnt(b[i][y]&b[j][y]&b[x][y]);
43         int r=i==x?1:(i==j||j==x?3:6);
44         ans=(ans+(1ll*_000*_111+1ll*_001*_110+1ll*_010*_101+1ll*_011*_100)%mod*pw[i+j+x]*r)%mod;
45     }cout<<ans<<endl;
46 }
80pts. Card Chang

 

T2: despite the wind and waves, sit back (cont.)

Pigeon pigeon the great God, etc. $ skyh $ talked about.

 

T3: fish and can not have both

Effect: interaction. Implement a function guess $ a $ n-aligned. You can call a function that returns the correct arrangement has the number of bits. $ N \ le 5000, limit \ le 10n $

First, in order to facilitate random out of a wrong row.

Then exchange relationship with the relatively $ \ frac {n (n-1)} {2} $ edges.

As it has been wrong row, so the results of this exchange will only increase the number of correct, then this edge on at least one digital homing.

Thus all the useful side are down, then the entire sequence was divided into a number of rings.

The question now is how to know which side usefulness within the legal queries.

It found that as long as there is no common point between the sides is so independently of each other's.

Then we can not specify a common point edge set at the same time to swap them and then $ count $. If several record that this group has at least one side in useful.

Then recursively partition which side is going to find useful.

So the question is how to $ \ frac {n (n-1)}) {2} $ sides divided into groups so as to minimize no common point.

Finding that both edges of the dots of the number and the group number is modulo $ $ a n-reasonable.

Because if there is a common point that is equivalent to a certain number on the lock. In order to make the mold equal within the same group, then the other should be equal to the number, and that is the heavy side. . .

Reason for this group and then divide and conquer, to get the last $ dfs $ ring on it.

However, there are a few small details to the card often, after all, this question should be $ O (nlogn) $ and comes with some big constant, but the card into a $ 10n $ also a very unscrupulous.

First, for a point if it's useful to have reached a degree of side 2 side so later on this point do not have to join the partition.

Second pass a parameter when the partition is all there on the side of the total contribution of $ count $. Then query son left and right son's value will be directly made the difference was.

And then the complexity of the final $ dfs $ ring number should be level, not a points level.

Then probably the last subtask $ 49199 $ passed. Unscrupulous people out of the question. .

 1 #include"game.h"
 2 using namespace std;
 3 #define S 5555
 4 int x[5555],y[5555],c,mt[5555],e[5555][3],al[5555],C,top;vector<int>a,r;
 5 void cl(int l,int r){for(int i=l;i<=r;++i)swap(a[x[i]],a[y[i]]);}
 6 void DaC(int l,int r,int zz){
 7     if(l==r){
 8         e[x[l]][++mt[x[l]]]=y[l];e[y[l]][++mt[y[l]]]=x[l];
 9         if(zz^1)e[x[l]][++mt[x[l]]]=y[l],e[y[l]][++mt[y[l]]]=x[l]; return;
10     }
11     cl(l,l+r>>1);int $=count(a);cl(l,l+r>>1);if($)DaC(l,l+r>>1,$);
12     if($!=zz)DaC((l+r>>1)+1,r,zz-$);
13 }
14 void dfs(int p,int nt=1){
15     al[p]=nt;top++;
16     for(int i=1;i<3;++i)if(al[e[p][i]]!=nt)swap(a[p],a[e[p][i]]),dfs(e[p][i],nt);
17 }
18 vector<int>guess(int n,int l){
19     a.resize(n);r.resize(n);
20     for(int i=1;i<=n;++i)a[i-1]=i;
21     srand(time(0));
22     while(count(a))random_shuffle(a.begin(),a.end());
23     for(int i=0;c=0,i<n;++i){
24         for(int j=0;j<n;++j)if(mt[j]!=2&&mt[(i-j+n)%n]!=2&&j<(i-j+n)%n)x[++c]=j,y[c]=(i-j+n)%n;
25         if(c){cl(1,c);int x=count(a);cl(1,c);if(x)DaC(1,c,x);}
26     }
27     for(int i=0,lc=0;i<n;++i)if(!al[i]){
28         top=1;
29         for(int j=0;j<n;++j)r[j]=a[j];
30         al[i]=1;swap(a[i],a[e[i][1]]);dfs(e[i][1]);
31         int C=count(a);if(C==lc+top){lc=C;continue;}
32         for(int j=0;j<n;++j)a[j]=r[j];lc+=top;
33         al[i]=2;swap(a[i],a[e[i][2]]);dfs(e[i][2],2);
34     }return a;
35 }
View Code

 

Guess you like

Origin www.cnblogs.com/hzoi-DeepinC/p/12359893.html
Recommended