답안 #855762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
855762 2023-10-01T18:13:35 Z annabeth9680 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
163 ms 160940 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 3010;
string grid[MAXN];
int cntI[MAXN][MAXN], cntO[MAXN][MAXN];
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int H,W; cin >> H >> W;
    for(int i = 0;i<H;++i){
        cin >> grid[i];
    }
    for(int i = 0;i<H;++i){
        int os = 0;
        for(int j = W-1;j>=0;--j){
            if(grid[i][j] == 'J'){
                cntO[i][j] = os;
                //cout << i << " " << j << " " << cntO[i][j] << "\n";
            }
            else if(grid[i][j] == 'O') os++;
        }
    }
    for(int i = 0;i<W;++i){
        int is = 0;
        for(int j = H-1;j>=0;--j){
            if(grid[j][i] == 'J'){
                cntI[j][i] = is;
                //cout << j << " " << i << " " << cntI[j][i] << "\n";
            }
            else if(grid[j][i] == 'I') is++;
        }
    }
    int ans = 0;
    for(int i = 0;i<H;++i){
        for(int j = 0;j<W;++j){
            if(grid[i][j] == 'J'){
                //cout << i << " " << j << " " << cntI[j][i] << " " << cntO[i][j] << "\n";
                ans += cntI[i][j]*cntO[i][j];
            }
        }
    }
    cout << ans << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 8760 KB Output is correct
9 Correct 1 ms 8792 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 1 ms 8792 KB Output is correct
12 Correct 1 ms 8796 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 8760 KB Output is correct
9 Correct 1 ms 8792 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 1 ms 8792 KB Output is correct
12 Correct 1 ms 8796 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 5 ms 27484 KB Output is correct
15 Correct 3 ms 23132 KB Output is correct
16 Correct 3 ms 15196 KB Output is correct
17 Correct 1 ms 4700 KB Output is correct
18 Correct 6 ms 27760 KB Output is correct
19 Correct 4 ms 27484 KB Output is correct
20 Correct 4 ms 27736 KB Output is correct
21 Correct 8 ms 27740 KB Output is correct
22 Correct 4 ms 27740 KB Output is correct
23 Correct 5 ms 27740 KB Output is correct
24 Correct 7 ms 27740 KB Output is correct
25 Correct 5 ms 27700 KB Output is correct
26 Correct 4 ms 27736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 8760 KB Output is correct
9 Correct 1 ms 8792 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 1 ms 8792 KB Output is correct
12 Correct 1 ms 8796 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 5 ms 27484 KB Output is correct
15 Correct 3 ms 23132 KB Output is correct
16 Correct 3 ms 15196 KB Output is correct
17 Correct 1 ms 4700 KB Output is correct
18 Correct 6 ms 27760 KB Output is correct
19 Correct 4 ms 27484 KB Output is correct
20 Correct 4 ms 27736 KB Output is correct
21 Correct 8 ms 27740 KB Output is correct
22 Correct 4 ms 27740 KB Output is correct
23 Correct 5 ms 27740 KB Output is correct
24 Correct 7 ms 27740 KB Output is correct
25 Correct 5 ms 27700 KB Output is correct
26 Correct 4 ms 27736 KB Output is correct
27 Correct 148 ms 159528 KB Output is correct
28 Correct 12 ms 105048 KB Output is correct
29 Correct 7 ms 16220 KB Output is correct
30 Correct 2 ms 4696 KB Output is correct
31 Correct 100 ms 134384 KB Output is correct
32 Correct 86 ms 160672 KB Output is correct
33 Correct 73 ms 160496 KB Output is correct
34 Correct 115 ms 155052 KB Output is correct
35 Correct 90 ms 160372 KB Output is correct
36 Correct 71 ms 160940 KB Output is correct
37 Correct 163 ms 160840 KB Output is correct
38 Correct 52 ms 134308 KB Output is correct
39 Correct 49 ms 134380 KB Output is correct