Submission #371883

#TimeUsernameProblemLanguageResultExecution timeMemory
371883Jarif_RahmanFurniture (JOI20_furniture)C++17
0 / 100
2 ms512 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<vector<bool>> v(n, vector<bool>(m, 0)); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++){ bool bl; cin >> bl; v[i][j] = bl; } int cur = n; vector<int> ff(n, m+1), ls(n, -1); vector<bool> block(n); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++){ if(!v[i][j]) continue; ff[i] = min(ff[i], j); ls[i] = j; if(i == 0 && !block[i]){ block[i] = 1; cur--; } else if(j >= ff[i-1]-1 && !block[i]){ block[i] = 1; cur--; } } int q; cin >> q; while(q--){ int x, y; cin >> x >> y; x--, y--; int cnt = 0; if(!block[x]){ if(x == 0) cnt++; else if(max(y, ls[x]) >= ff[x-1]-1) cnt++; } if(x+1 < n && !block[x+1]){ if(ls[x+1] >= min(y, ff[x])-1) cnt++; } if(cur-cnt == 0){ cout << "0\n"; continue; } cout << "1\n"; if(!block[x]){ if(x == 0) block[x] = 1; else if(max(y, ls[x]) >= ff[x-1]-1) block[x] = 1; } if(x+1 < n && !block[x+1]){ if(ls[x+1] >= min(y, ff[x])-1) block[x+1] = 1; } ff[x] = min(ff[x], y); ls[x] = max(ls[x], y); cur-=cnt; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...