Submission #1009841

#TimeUsernameProblemLanguageResultExecution timeMemory
1009841pccGame (APIO22_game)C++17
12 / 100
5 ms9048 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int mxk = 1010; const int mxn = 3e4+10; bool flag = false; char cnt[mxk][mxn]; void add(int row,int k){ cnt[row][k]++; if(cnt[row][k]>=2)flag = true; return; } struct GRAPH{ short head[mxn*3],nid[mxn*3],to[mxn*3]; short ptr; GRAPH(){ ptr = 0; memset(head,0,sizeof(head)); } void add(int a,int b){ ptr++; nid[ptr] = head[a]; head[a] = ptr; to[ptr] = b; return; } }; GRAPH g,rg; struct DS{ bitset<mxn> vis,rvis; int id; DS(int ii = 0):id(ii){vis.reset();rvis.reset();} void DFS(int now){ if(vis[now])return; vis[now] = 1; add(id,now); for(auto eid = g.head[now];eid;eid = g.nid[eid]){ int nxt = g.to[eid]; if(vis[nxt])continue; DFS(nxt); } return; } void RDFS(int now){ if(rvis[now])return; rvis[now] = 1; add(id,now); for(auto eid = rg.head[now];eid;eid = rg.nid[eid]){ int nxt = rg.to[eid]; if(rvis[nxt])continue; RDFS(nxt); } } void add_edge(int a,int b){ if(vis[a])DFS(b); if(rvis[b])RDFS(a); return; } }; DS arr[mxk]; int N,K; void init(int n, int k) { N = n,K = k; for(int i = 0;i<k;i++){ arr[i].id = i; arr[i].vis[i] = arr[i].rvis[i] = 1; } for(int i = 0;i<=k-2;i++){ g.add(i,i+1); rg.add(i+1,i); for(int j = 0;j<k;j++){ arr[j].add_edge(i,i+1); } } flag = false; /* cerr<<"INIT DONE!"<<endl; for(int i = 0;i<K;i++){ for(int j = 0;j<N;j++)cerr<<arr[i].vis[j];cerr<<endl; for(int j = 0;j<N;j++)cerr<<arr[i].rvis[j];cerr<<endl; cerr<<endl; } */ return; } int add_teleporter(int u, int v) { if(u == v){ return (u<K); } for(int i = 0;i<K;i++){ g.add(u,v); rg.add(v,u); arr[i].add_edge(u,v); } return flag; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...