Submission #99969

# Submission time Handle Problem Language Result Execution time Memory
99969 2019-03-09T04:13:15 Z oolimry Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
530 ms 114824 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    //freopen("i.txt","r",stdin);
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int rows, cols;
    cin >> rows >> cols;
    int arr[rows][cols];
    for(int r = 0;r < rows;r++){
        string s;
        cin >> s;
        for(int c = 0;c < cols;c++){
            if(s[c] == 'J') arr[r][c] = 0;
            else if(s[c] == 'O') arr[r][c] = 1;
            else arr[r][c] = 2;
        }
    }

    int O[rows][cols];
    int I[rows][cols];
    for(int r = 0;r < rows;r++){
        for(int c = 0;c < cols;c++){
            O[r][c] = 0;
            I[r][c] = 0;
        }
    }

    for(int r = 0;r < rows;r++){
        for(int c = cols-1;c >= 0;c--){
            if(arr[r][c] == 1) O[r][c]++;
            if(c != cols-1) O[r][c] += O[r][c+1];
        }
    }

    for(int c = 0;c < cols;c++){
        for(int r = rows-1;r >= 0;r--){
            if(arr[r][c] == 2) I[r][c]++;
            if(r != rows-1) I[r][c] += I[r+1][c];
        }
    }

    long long ans = 0ll;
    for(int r = 0;r < rows;r++){
        for(int c = 0;c < cols;c++){
            if(arr[r][c] == 0){
                long long x = O[r][c];
                long long y = I[r][c];
                ans += x * y;
            }
        }
    }

    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 9 ms 2688 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 6 ms 1932 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 11 ms 3456 KB Output is correct
19 Correct 10 ms 3328 KB Output is correct
20 Correct 9 ms 3328 KB Output is correct
21 Correct 13 ms 3456 KB Output is correct
22 Correct 9 ms 3328 KB Output is correct
23 Correct 12 ms 3456 KB Output is correct
24 Correct 12 ms 3456 KB Output is correct
25 Correct 8 ms 3328 KB Output is correct
26 Correct 8 ms 3456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 9 ms 2688 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 6 ms 1932 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 11 ms 3456 KB Output is correct
19 Correct 10 ms 3328 KB Output is correct
20 Correct 9 ms 3328 KB Output is correct
21 Correct 13 ms 3456 KB Output is correct
22 Correct 9 ms 3328 KB Output is correct
23 Correct 12 ms 3456 KB Output is correct
24 Correct 12 ms 3456 KB Output is correct
25 Correct 8 ms 3328 KB Output is correct
26 Correct 8 ms 3456 KB Output is correct
27 Correct 524 ms 108408 KB Output is correct
28 Correct 3 ms 640 KB Output is correct
29 Correct 18 ms 8448 KB Output is correct
30 Correct 3 ms 640 KB Output is correct
31 Correct 368 ms 79776 KB Output is correct
32 Correct 403 ms 113912 KB Output is correct
33 Correct 411 ms 114412 KB Output is correct
34 Correct 456 ms 92536 KB Output is correct
35 Correct 444 ms 113964 KB Output is correct
36 Correct 426 ms 114424 KB Output is correct
37 Correct 530 ms 114824 KB Output is correct
38 Correct 284 ms 79096 KB Output is correct
39 Correct 349 ms 79352 KB Output is correct