답안 #371883

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
371883 2021-02-27T06:39:36 Z Jarif_Rahman Furniture (JOI20_furniture) C++17
0 / 100
2 ms 512 KB
#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;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -