Submission #965100

#TimeUsernameProblemLanguageResultExecution timeMemory
965100Darren0724Cell Automaton (JOI23_cell)C++17
16 / 100
239 ms127884 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(),x.end(); #define LCBorz ios_base::sync_with_stdio(false);cin.tie(0); #define endl '\n' const int C=2002; const int N=C<<1|1; const int INF=1e9; const int lim=1000; vector<int> dx={-1,0,1,0},dy={0,1,0,-1}; int dis[N][N],ans[N]; int32_t main(){ LCBorz; for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ dis[i][j]=INF; } } int n,q1;cin>>n>>q1; queue<pair<int,int>> q; for(int i=0;i<n;i++){ int a,b;cin>>a>>b; dis[a+C][b+C]=0; q.push({a+C,b+C}); } while(q.size()){ auto [a,b]=q.front(); q.pop(); if(dis[a][b]>lim)continue; ans[dis[a][b]]++; for(int k=0;k<4;k++){ int c=a+dx[k]; int d=b+dy[k]; if(dis[c][d]==INF){ dis[c][d]=dis[a][b]+1; q.push({c,d}); } } } for(int i=0;i<q1;i++){ int t;cin>>t; cout<<ans[t]<<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...