# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
421541 | 2021-06-09T08:52:26 Z | 장태환(#7576) | Collapse (JOI18_collapse) | C++17 | 15000 ms | 5780 KB |
#include "collapse.h" #include <string.h> using namespace std; int st[100100]; int e[100100]; int d[200100]; unsigned int vis[200200>>6]; vector<pair<int,int>>q[100100]; int sta[100100]; int siz; vector<int> simulateCollapse(int N,vector<int> T,vector<int> X,vector<int> Y,vector<int> W,vector<int> P) { memset(vis,-1,sizeof(vis)); vector<int>ann=vector<int>(W.size(), 0); int i; int M=T.size(); for(i=0;i<M;i++) { if(T[i]) { e[X[i]]--; e[Y[i]]--; } else { e[X[i]]++; e[Y[i]]++; st[X[i]+1]=max(st[X[i]+1],e[X[i]]); st[Y[i]+1]=max(st[Y[i]+1],e[Y[i]]); } } for(i=0;i<N;i++) { if(i) st[i]+=st[i-1]; e[i]=st[i]; } int C=P.size(); for(i=0;i<C;i++) { q[W[i]].push_back({P[i],i}); } for(i=0;i<M;i++) { int ty=T[i]; int s=X[i]; int en=Y[i]; register int j; if(ty) { int fi=st[s]; int se=e[s]; for(j=fi;j<se;j++) { if(d[j]==en) { d[j]=d[se-1]; break; } } e[s]--; fi=st[en]; se=e[en]; for(j=fi;j<se;j++) { if(d[j]==s) { d[j]=d[se-1]; break; } } e[en]--; } else { d[e[s]++]=en; d[e[en]++]=s; } for(j=0;j<q[i].size();j++) { int div=q[i][j].first+1; int cur=0; int an=0; for(j=0;j<div;j++) { vis[j>>5]^=1U<<(j&31); } while(cur<div) { an++; sta[siz++]=cur; while(siz) { int cou=sta[--siz]; register int k; for(k=st[cou];k<e[cou];k++) { if(!(vis[d[k]>>5]&(1U<<(d[k]&31)))) { vis[d[k]>>5]|=1U<<(d[k]&31); sta[siz++]=d[k]; } } } cur++; while((vis[cur>>5]&(1U<<(cur&31)))) { cur++; } } for(j=div;j<N;j++) { vis[j>>5]^=1U<<(j&31); } cur=N-1; while(cur>=div) { an++; sta[siz++]=cur; while(siz) { int cou=sta[--siz]; register int k; for(k=st[cou];k<e[cou];k++) { if(!(vis[d[k]>>5]&(1U<<(d[k]&31)))) { vis[d[k]>>5]|=1U<<(d[k]&31); sta[siz++]=d[k]; } } } cur--; while(cur&&(vis[cur>>5]&(1U<<(cur&31)))) { cur--; } } ann[q[i][j].second]=an; } } return ann; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 275 ms | 3020 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 15073 ms | 5724 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 15071 ms | 5780 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 275 ms | 3020 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |