Submission #306778

# Submission time Handle Problem Language Result Execution time Memory
306778 2020-09-26T09:15:18 Z MrDomino Furniture (JOI20_furniture) C++14
5 / 100
5000 ms 1816 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2000 + 7;
int n;
int m;
int a[N][N];
int down[N][N];

void full()
{
    down[n + 1][m] = down[n][m + 1] = 1;
    for (int i = n; i >= 1; i--)
    {
        for (int j = m; j >= 1; j--)
        {
            if (a[i][j] == 0)
            {
                down[i][j] = (down[i + 1][j] > 0) + (down[i][j + 1] > 0);
            }
            else
            {
                down[i][j] = 0;
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> a[i][j];
        }
    }
    int q;
    cin >> q;
    for (int i = 1; i <= q; i++)
    {
        int r, c;
        cin >> r >> c;
        a[r][c] = 1;
        full();
        if (down[1][1] == 0)
        {
            a[r][c] = 0;
            cout << "0\n";
        }
        else
        {
            cout << "1\n";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1024 KB Output is correct
2 Correct 49 ms 1272 KB Output is correct
3 Correct 111 ms 1152 KB Output is correct
4 Correct 253 ms 1412 KB Output is correct
5 Correct 279 ms 1368 KB Output is correct
6 Correct 356 ms 1400 KB Output is correct
7 Correct 270 ms 1400 KB Output is correct
8 Correct 302 ms 1400 KB Output is correct
9 Correct 232 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1024 KB Output is correct
2 Correct 49 ms 1272 KB Output is correct
3 Correct 111 ms 1152 KB Output is correct
4 Correct 253 ms 1412 KB Output is correct
5 Correct 279 ms 1368 KB Output is correct
6 Correct 356 ms 1400 KB Output is correct
7 Correct 270 ms 1400 KB Output is correct
8 Correct 302 ms 1400 KB Output is correct
9 Correct 232 ms 1400 KB Output is correct
10 Execution timed out 5101 ms 1816 KB Time limit exceeded
11 Halted 0 ms 0 KB -