Submission #965329

#TimeUsernameProblemLanguageResultExecution timeMemory
965329pccCell Automaton (JOI23_cell)C++17
0 / 100
35 ms50720 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,popcnt,sse4") #define pii pair<int,int> #define fs first #define sc second const int mxn = 6010; const int sh = mxn>>1; int N,Q; int req[mxn]; pii dir[] = {{-1,0},{1,0},{0,1},{0,-1}}; vector<pii> v; vector<pii> vv; int arr[mxn][mxn]; int ans = 0; void move(){ ans = 0; vv.clear(); for(auto &i:v){ for(auto &d:dir){ if(!arr[i.fs+d.fs][i.sc+d.sc]){ arr[i.fs+d.fs][i.sc+d.sc] = true; vv.push_back(pii(i.fs+d.fs,i.sc+d.sc)); ans++; } } } vv.swap(v); return; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N>>Q; for(int i = 0;i<N;i++){ int r,c; cin>>r>>c; arr[r+sh][c+sh] = 1; v.push_back(pii(r+sh,c+sh)); } int t = 0; while(Q--){ int k; cin>>k; while(t<k){ t++; move(); } cout<<ans<<'\n'; /* for(auto &i:arr){ for(auto &j:i)cout<<j;cout<<endl; }cout<<endl; */ } return 0; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...