Submission #1053729

#TimeUsernameProblemLanguageResultExecution timeMemory
1053729Szymon_PilipczukFurniture (JOI20_furniture)C++17
0 / 100
4 ms348 KiB
#include <iostream> #include <vector> using namespace std; int n; int m; vector <vector <int>> store; vector<int> emptyd; void change(int i1,int i2) { store[i1][i2] = 1; emptyd[i1+i2]--; if (i1<n-1 && i2 >0) { if (store[i1+1][i2-1] == 1) { if (store[i1+1][i2] == 0) { change(i1+1,i2); } if (store[i1][i2-1] == 0) { change(i1,i2-1); } } } if (i1 > 0 && i2<m-1) { if (store[i1-1][i2+1] == 1) { if (store[i1-1][i2] == 0) { change(i1-1,i2); } if (store[i1][i2+1]==0) { change(i1,i2+1); } } } if(i1 == n-1 && i2 > 0&&store[i1][i2-1] == 0) { change(i1,i2-1); } if(i1 > 0 && i2 == m-1&&store[i1-1][i2] == 0) { change(i1-1,i2); } } int main() { cin>>n>>m; for(int i = 0;i<m;i++) { emptyd.push_back(min(n,i+1)); } for(int i = m;i<m+n-1;i++) { emptyd.push_back(min(m,m+n-1-i)); } vector<int> t; for(int j = 0;j<m;j++) { t.push_back(0); } for(int i = 0;i<n;i++) { store.push_back(t); } int cu; for(int i = 0;i<n;i++) { for (int j = 0;j<m;j++) { cin>>cu; if(cu==1) { change(i,j); } } } int Q; cin>>Q; int x,y; for(int i = 0; i<Q;i++) { cin>>x>>y; x--; y--; if(emptyd[x+y]<=1) { cout<<0<<"\n"; } else { cout<<1<<"\n"; change(x,y); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...