Submission #569605

# Submission time Handle Problem Language Result Execution time Memory
569605 2022-05-27T14:40:24 Z OttoTheDino Furniture (JOI20_furniture) C++17
5 / 100
5000 ms 9756 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,e)                  for (int i = s; i <= e; ++i)
#define rrep(i,s,e)                 for (int i = s; i >= e; --i)
#define pb                          push_back
#define pf                          push_front
#define fi                          first
#define se                          second
#define all(a)                      a.begin(), a.end()
#define len(a)                      (int)a.size()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;

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

    int n, m; cin >> n >> m;
    int g[n+2][m+2] = {};
    rep (i,1,n) {
        rep (j,1,m) {
            cin >> g[i][j], g[i][j]^=1;
        }
    }

    int Q; cin >> Q;

    while (Q--) {

        int x, y; cin >> x >> y;

        int g2[n+2][m+2] = {};

        memcpy(g2, g, sizeof(g));

        g2[x][y] = 0;

        rrep (i,n,1) {
            rrep (j,m,1) {
                bool b = 0;
                if (i<n) b |= g2[i+1][j];
                if (j<m) b |= g2[i][j+1];
                if (i==n && j==m) b = 1;
                g2[i][j] &= b;
            }
        }
        
        cout << g2[1][1] << "\n";
        if (g2[1][1]) g[x][y] = 0;
    }
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 53 ms 340 KB Output is correct
3 Correct 125 ms 404 KB Output is correct
4 Correct 257 ms 560 KB Output is correct
5 Correct 287 ms 452 KB Output is correct
6 Correct 405 ms 468 KB Output is correct
7 Correct 360 ms 588 KB Output is correct
8 Correct 382 ms 588 KB Output is correct
9 Correct 359 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 53 ms 340 KB Output is correct
3 Correct 125 ms 404 KB Output is correct
4 Correct 257 ms 560 KB Output is correct
5 Correct 287 ms 452 KB Output is correct
6 Correct 405 ms 468 KB Output is correct
7 Correct 360 ms 588 KB Output is correct
8 Correct 382 ms 588 KB Output is correct
9 Correct 359 ms 476 KB Output is correct
10 Correct 4898 ms 1292 KB Output is correct
11 Correct 231 ms 460 KB Output is correct
12 Execution timed out 5041 ms 9756 KB Time limit exceeded
13 Halted 0 ms 0 KB -