답안 #108723

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
108723 2019-05-01T07:40:55 Z tictaccat Bitaro the Brave (JOI19_ho_t1) C++11
100 / 100
831 ms 181192 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));
int ups1[MAX][MAX], ups2[MAX][MAX], lefts1[MAX][MAX], lefts2[MAX][MAX];

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

    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--) {
            ups1[i][j] = ups1[i+1][j];
            ups2[i][j] = ups2[i+1][j];
            lefts1[i][j] = lefts1[i][j+1];
            lefts2[i][j] = lefts2[i][j+1];
            ll ways = 0;
            if (grid[i][j] == 0) {
                ways += (ll)ups2[i][j]*lefts1[i][j];
            }
            else if (grid[i][j] == 1) {
                ups1[i][j]++;
                lefts1[i][j]++;
            }
            else if (grid[i][j] == 2) {
                ups2[i][j]++;
                lefts2[i][j]++;
            }           
            c += ways;
        }
    }

    cout << c << "\n";


}
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 35960 KB Output is correct
2 Correct 35 ms 35928 KB Output is correct
3 Correct 34 ms 35960 KB Output is correct
4 Correct 33 ms 36108 KB Output is correct
5 Correct 36 ms 37628 KB Output is correct
6 Correct 35 ms 37624 KB Output is correct
7 Correct 33 ms 37496 KB Output is correct
8 Correct 36 ms 37624 KB Output is correct
9 Correct 38 ms 37596 KB Output is correct
10 Correct 36 ms 37496 KB Output is correct
11 Correct 39 ms 37624 KB Output is correct
12 Correct 35 ms 37632 KB Output is correct
13 Correct 33 ms 37500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 35960 KB Output is correct
2 Correct 35 ms 35928 KB Output is correct
3 Correct 34 ms 35960 KB Output is correct
4 Correct 33 ms 36108 KB Output is correct
5 Correct 36 ms 37628 KB Output is correct
6 Correct 35 ms 37624 KB Output is correct
7 Correct 33 ms 37496 KB Output is correct
8 Correct 36 ms 37624 KB Output is correct
9 Correct 38 ms 37596 KB Output is correct
10 Correct 36 ms 37496 KB Output is correct
11 Correct 39 ms 37624 KB Output is correct
12 Correct 35 ms 37632 KB Output is correct
13 Correct 33 ms 37500 KB Output is correct
14 Correct 56 ms 47096 KB Output is correct
15 Correct 37 ms 42748 KB Output is correct
16 Correct 45 ms 42232 KB Output is correct
17 Correct 34 ms 36216 KB Output is correct
18 Correct 67 ms 48120 KB Output is correct
19 Correct 60 ms 47864 KB Output is correct
20 Correct 66 ms 47908 KB Output is correct
21 Correct 64 ms 48088 KB Output is correct
22 Correct 57 ms 47992 KB Output is correct
23 Correct 74 ms 47768 KB Output is correct
24 Correct 65 ms 48120 KB Output is correct
25 Correct 66 ms 47864 KB Output is correct
26 Correct 64 ms 47736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 35960 KB Output is correct
2 Correct 35 ms 35928 KB Output is correct
3 Correct 34 ms 35960 KB Output is correct
4 Correct 33 ms 36108 KB Output is correct
5 Correct 36 ms 37628 KB Output is correct
6 Correct 35 ms 37624 KB Output is correct
7 Correct 33 ms 37496 KB Output is correct
8 Correct 36 ms 37624 KB Output is correct
9 Correct 38 ms 37596 KB Output is correct
10 Correct 36 ms 37496 KB Output is correct
11 Correct 39 ms 37624 KB Output is correct
12 Correct 35 ms 37632 KB Output is correct
13 Correct 33 ms 37500 KB Output is correct
14 Correct 56 ms 47096 KB Output is correct
15 Correct 37 ms 42748 KB Output is correct
16 Correct 45 ms 42232 KB Output is correct
17 Correct 34 ms 36216 KB Output is correct
18 Correct 67 ms 48120 KB Output is correct
19 Correct 60 ms 47864 KB Output is correct
20 Correct 66 ms 47908 KB Output is correct
21 Correct 64 ms 48088 KB Output is correct
22 Correct 57 ms 47992 KB Output is correct
23 Correct 74 ms 47768 KB Output is correct
24 Correct 65 ms 48120 KB Output is correct
25 Correct 66 ms 47864 KB Output is correct
26 Correct 64 ms 47736 KB Output is correct
27 Correct 831 ms 181192 KB Output is correct
28 Correct 75 ms 73592 KB Output is correct
29 Correct 85 ms 48824 KB Output is correct
30 Correct 37 ms 36308 KB Output is correct
31 Correct 584 ms 157288 KB Output is correct
32 Correct 715 ms 180828 KB Output is correct
33 Correct 711 ms 180440 KB Output is correct
34 Correct 586 ms 176252 KB Output is correct
35 Correct 631 ms 180856 KB Output is correct
36 Correct 621 ms 180600 KB Output is correct
37 Correct 711 ms 180952 KB Output is correct
38 Correct 537 ms 157276 KB Output is correct
39 Correct 471 ms 156920 KB Output is correct