Submission #108719

# Submission time Handle Problem Language Result Execution time Memory
108719 2019-05-01T07:33:08 Z tictaccat Bitaro the Brave (JOI19_ho_t1) C++14
0 / 100
286 ms 275456 KB
//testing

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX = 3000 + 10;

int H,W;
vector<vector<int>> grid(MAX,vector<int>(MAX));
vector<int> ups[MAX][MAX], lefts[MAX][MAX];

int main() {
    
    cin >> H >> W;

    for (int j = 0; j <= W; j++) ups[H][j] = lefts[H][j] = vector<int>(3,0);
    for (int i = 0; i <= H; i++) ups[i][W] = lefts[i][W] = vector<int>(3,0);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c; cin >> c;
            if (c == 'J') grid[i][j] = 0;
            else if (c == 'O') grid[i][j] = 1;
            else grid[i][j] = 2;
         }
    }

    ll c = 0;

    for (int i = H-1; i >= 0; i--) {
        for (int j = W-1; j >= 0; j--) {
            ups[i][j] = move(ups[i+1][j]);
            lefts[i][j] = move(lefts[i][j+1]);
            ll ways = 0;
            if (grid[i][j] == 0) {
                ways += (ll)ups[i][j][1]*lefts[i][j][2];
                ways += (ll)ups[i][j][2]*lefts[i][j][1];
            }
            ups[i][j][grid[i][j]]++;
            lefts[i][j][grid[i][j]]++;
            c += ways;
        }
    }

    cout << c << "\n";


}
# Verdict Execution time Memory Grader output
1 Runtime error 286 ms 275456 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 286 ms 275456 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 286 ms 275456 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -