답안 #882440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
882440 2023-12-03T07:42:28 Z hennessey Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
524 ms 220924 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main() {
    //your code goes here
    int n, m;
    cin >> n >> m;
    vector <vector <int>> arr(n, vector <int>(m));
    vector <vector <int>> pref(n, vector <int>(m));
    vector <vector <int>> pref2(n, vector <int>(m));
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for(int j = 0; j < m; j++) {
            if(s[j] == 'J') {
                arr[i][j] = 1;
            } else if(s[j] == 'O') {
                arr[i][j] = 2;
            } else {
                arr[i][j] = 3;
            }
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = m-1; j >= 0; j--) {
            if(arr[i][j] == 2) {
                pref[i][j] += 1;
            }
            if(j == m-1) {
                continue;
            }
            pref[i][j] += pref[i][j+1];
        }
    }
    for(int i = 0; i < m; i++) {
        for(int j = n-1; j >= 0; j--) {
            if(arr[j][i] == 3) {
                pref2[j][i] += 1;
            }
            if(j == n-1) {
                continue;
            }
            pref2[j][i] += pref2[j+1][i];
        }
    }
    int total = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(arr[i][j] == 1) {
                int val1 = pref[i][j];
                int val2 = pref2[i][j];
                // cout << val1 << " " << val2 << " " << i << " " << j << endl;
                total += (val1*val2);
            }
        }
    }
    cout << total << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 440 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 856 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 440 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 856 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 8 ms 4956 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 4 ms 3420 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 10 ms 6600 KB Output is correct
19 Correct 8 ms 6488 KB Output is correct
20 Correct 8 ms 6492 KB Output is correct
21 Correct 10 ms 6492 KB Output is correct
22 Correct 9 ms 6368 KB Output is correct
23 Correct 8 ms 6492 KB Output is correct
24 Correct 10 ms 6492 KB Output is correct
25 Correct 8 ms 6236 KB Output is correct
26 Correct 8 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 440 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 856 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 8 ms 4956 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 4 ms 3420 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 10 ms 6600 KB Output is correct
19 Correct 8 ms 6488 KB Output is correct
20 Correct 8 ms 6492 KB Output is correct
21 Correct 10 ms 6492 KB Output is correct
22 Correct 9 ms 6368 KB Output is correct
23 Correct 8 ms 6492 KB Output is correct
24 Correct 10 ms 6492 KB Output is correct
25 Correct 8 ms 6236 KB Output is correct
26 Correct 8 ms 6492 KB Output is correct
27 Correct 506 ms 208600 KB Output is correct
28 Correct 2 ms 1116 KB Output is correct
29 Correct 20 ms 16184 KB Output is correct
30 Correct 1 ms 860 KB Output is correct
31 Correct 336 ms 153360 KB Output is correct
32 Correct 443 ms 219480 KB Output is correct
33 Correct 444 ms 219984 KB Output is correct
34 Correct 390 ms 178344 KB Output is correct
35 Correct 436 ms 219388 KB Output is correct
36 Correct 447 ms 220116 KB Output is correct
37 Correct 524 ms 220924 KB Output is correct
38 Correct 303 ms 152184 KB Output is correct
39 Correct 304 ms 152980 KB Output is correct