Submission #1053692

#TimeUsernameProblemLanguageResultExecution timeMemory
1053692SzymonKrzywdaFurniture (JOI20_furniture)C++17
0 / 100
5 ms2396 KiB
#include <bits/stdc++.h> using namespace std; int przekatne[2010]; int tablica[2010][2010]; void rozlej(int a, int b){ queue<pair<int,int>> kolejka; kolejka.push({a,b}); while (!kolejka.empty()){ int y = kolejka.front().first; int x = kolejka.front().second; kolejka.pop(); //cout << y << " " << x << endl; if (tablica[y+1][x-1]==1){ //cout << y+1 << " " << x-1 << " " << tablica[y+1][x-1] << endl; if (tablica[y][x-1]==0){ przekatne[y+x-1]--; tablica[y][x-1]=1; kolejka.push({y,x-1}); } if (tablica[y+1][x]==0){ przekatne[y+1+x]--; tablica[y+1][x]=1; kolejka.push({y+1,x}); } } if (tablica[y-1][x+1]==1){ if (tablica[y][x+1]==0){ przekatne[y+x+1]--; tablica[y][x+1]=1; kolejka.push({y,x+1}); } if (tablica[y-1][x]==0){ przekatne[y-1+x]--; tablica[y-1][x]=1; kolejka.push({y-1,x}); } } } } int main(){ int n,m,q,a,b; cin >> n >> m; for (int i=0; i<n+2; i++){ for (int j=0; j<m+2; j++){ tablica[i][j] = 1; } } for (int y=1; y<=n; y++){ for (int x=1; x<=m; x++){ cin >> tablica[y][x]; if (!tablica[y][x]) przekatne[y+x]++; } } for (int y=1; y<=n; y++){ for (int x=1; x<=m; x++){ if (tablica[y][x]) rozlej(y,x); } } cin >> q; for (int k=0; k<q; k++){ cin >> a >> b; if (przekatne[a+b]>1) { przekatne[a+b]--; tablica[a][b]=1; rozlej(a,b); cout << 1 << endl; } else cout << tablica[a][b] << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...