Submission #561905

# Submission time Handle Problem Language Result Execution time Memory
561905 2022-05-13T18:19:34 Z 4fecta Furniture (JOI20_furniture) C++17
0 / 100
109 ms 724 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define boost() cin.tie(0), cin.sync_with_stdio(0)

const int MN = 1005;

int n, m, q, r, c, a[MN][MN], reach1[MN], reach2[MN];

int32_t main() {
    boost();

    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }
    cin >> q;
    while (q--) {
        cin >> r >> c;
        a[r][c] = 1;
        int ok = 1;
        for (int i = 1; i <= n; i++) {
            reach1[i] = m + 1;
            for (int j = m; j > 0; j--) {
                if (a[i][j] && j >= reach1[i - 1] - 1) reach1[i] = j;
            }
            if (reach1[i] == 1) ok = 0;
        }
        if (reach1[n] <= m) ok = 0;
        for (int j = 1; j <= m; j++) {
            reach2[j] = n + 1;
            for (int i = n; i > 0; i--) {
                if (a[i][j] && i >= reach2[j - 1] - 1) reach2[j] = i;
            }
            if (reach2[j] == 1) ok = 0;
        }
        if (reach2[m] <= n) ok = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (j >= reach1[i] && i >= reach2[j]) ok = 0;
            }
        }
        a[r][c] = ok;
        printf("%lld\n", ok);
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 596 KB Output is correct
2 Incorrect 109 ms 724 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 596 KB Output is correct
2 Incorrect 109 ms 724 KB Output isn't correct
3 Halted 0 ms 0 KB -