Submission #403420

# Submission time Handle Problem Language Result Execution time Memory
403420 2021-05-13T07:14:21 Z lyc None (KOI17_shell) C++14
46 / 100
512 ms 18096 KB
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)
typedef pair<int,int> ii;

const int mxN = 1505;

int N, A[mxN][mxN], B[mxN][mxN], up[mxN][mxN], S;

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

    cin >> N;

    FOR(i,1,N){
        FOR(j,1,N){
            cin >> A[i][j];

            B[i][j] = max(B[i-1][j], B[i][j-1]) + A[i][j];
            S += B[i][j];
        }
    }

    cout << S << '\n';
    FOR(i,1,N){
        char op;
        int r, c, v;
        cin >> op >> r >> c;
        v = (op == 'U' ? 1 : -1);

        queue<ii> q;
        A[r][c] += v;
        B[r][c] += v;
        S += v;
        q.push(ii(r,c));

        while (!q.empty()) {
            auto u = q.front(); q.pop();
            int dr[] = {0,1};
            int dc[] = {1,0};
            FOR(k,0,1){
                int nr = u.first + dr[k], nc = u.second + dc[k];
                if (nr <= N && nc <= N &&
                        max(B[nr-1][nc], B[nr][nc-1]) + A[nr][nc] != B[nr][nc]) {
                    B[nr][nc] += v;
                    S += v;
                    q.push(ii(nr,nc));
                }
            }
        }

        cout << S << '\n';
    }
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 1100 KB Output is correct
2 Correct 2 ms 1100 KB Output is correct
3 Correct 6 ms 1100 KB Output is correct
4 Correct 15 ms 1100 KB Output is correct
5 Correct 14 ms 1200 KB Output is correct
6 Correct 15 ms 1200 KB Output is correct
7 Correct 3 ms 1100 KB Output is correct
8 Correct 3 ms 1100 KB Output is correct
9 Correct 3 ms 1100 KB Output is correct
10 Correct 2 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 189 ms 17904 KB Output is correct
2 Correct 189 ms 17912 KB Output is correct
3 Correct 512 ms 18008 KB Output is correct
4 Correct 158 ms 17988 KB Output is correct
5 Correct 164 ms 17944 KB Output is correct
6 Correct 186 ms 17900 KB Output is correct
7 Correct 189 ms 17988 KB Output is correct
8 Correct 159 ms 17964 KB Output is correct
9 Correct 162 ms 17988 KB Output is correct
10 Correct 161 ms 17908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1100 KB Output is correct
2 Correct 2 ms 1100 KB Output is correct
3 Correct 6 ms 1100 KB Output is correct
4 Correct 15 ms 1100 KB Output is correct
5 Correct 14 ms 1200 KB Output is correct
6 Correct 15 ms 1200 KB Output is correct
7 Correct 3 ms 1100 KB Output is correct
8 Correct 3 ms 1100 KB Output is correct
9 Correct 3 ms 1100 KB Output is correct
10 Correct 189 ms 17904 KB Output is correct
11 Correct 189 ms 17912 KB Output is correct
12 Correct 512 ms 18008 KB Output is correct
13 Correct 158 ms 17988 KB Output is correct
14 Correct 164 ms 17944 KB Output is correct
15 Correct 186 ms 17900 KB Output is correct
16 Correct 189 ms 17988 KB Output is correct
17 Correct 159 ms 17964 KB Output is correct
18 Correct 162 ms 17988 KB Output is correct
19 Correct 161 ms 17908 KB Output is correct
20 Correct 2 ms 1100 KB Output is correct
21 Incorrect 221 ms 18096 KB Output isn't correct
22 Halted 0 ms 0 KB -