답안 #807132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
807132 2023-08-04T13:51:04 Z annabeth9680 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
307 ms 161592 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int H,W; cin >> H >> W;
    vector<vector<ll>> suforbs(H,vector<ll>(W)), sufing(W,vector<ll>(H));
    vector<string> grid(H);
    for(int i = 0;i<H;++i){
        cin >> grid[i];
    }
    for(int i = 0;i<H;++i){
        suforbs[i][W-1] = ((grid[i][W-1] == 'O') ? 1 : 0);
        for(int j = W-2;j>=0;--j){
            if(grid[i][j] == 'O') suforbs[i][j] = suforbs[i][j+1]+1;
            else suforbs[i][j] = suforbs[i][j+1];
        }
    }
    for(int i = 0;i<W;++i){
        sufing[i][H-1] = ((grid[H-1][i] == 'I') ? 1 : 0);
        //cout << "ok";
        for(int j = H-2;j>=0;--j){
            if(grid[j][i] == 'I') sufing[i][j] = sufing[i][j+1]+1;
            else sufing[i][j] = sufing[i][j+1];
        }
        //cout << "ok";
    }
    //cout << "ok";
    ll ans = 0;
    for(int i = 0;i<H-1;++i){
        for(int j = 0;j<W-1;++j){
            if(grid[i][j] == 'J'){
                ans += suforbs[i][j+1]*sufing[j][i+1];
            }
        }
    }
    cout << ans << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 6 ms 3584 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 4 ms 2516 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 8 ms 4692 KB Output is correct
19 Correct 6 ms 4308 KB Output is correct
20 Correct 8 ms 4564 KB Output is correct
21 Correct 8 ms 4976 KB Output is correct
22 Correct 7 ms 4564 KB Output is correct
23 Correct 7 ms 4796 KB Output is correct
24 Correct 8 ms 4920 KB Output is correct
25 Correct 6 ms 4564 KB Output is correct
26 Correct 7 ms 4820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 6 ms 3584 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 4 ms 2516 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 8 ms 4692 KB Output is correct
19 Correct 6 ms 4308 KB Output is correct
20 Correct 8 ms 4564 KB Output is correct
21 Correct 8 ms 4976 KB Output is correct
22 Correct 7 ms 4564 KB Output is correct
23 Correct 7 ms 4796 KB Output is correct
24 Correct 8 ms 4920 KB Output is correct
25 Correct 6 ms 4564 KB Output is correct
26 Correct 7 ms 4820 KB Output is correct
27 Correct 302 ms 153292 KB Output is correct
28 Correct 2 ms 852 KB Output is correct
29 Correct 17 ms 12116 KB Output is correct
30 Correct 1 ms 700 KB Output is correct
31 Correct 215 ms 113868 KB Output is correct
32 Correct 243 ms 160612 KB Output is correct
33 Correct 253 ms 161104 KB Output is correct
34 Correct 252 ms 132132 KB Output is correct
35 Correct 267 ms 160656 KB Output is correct
36 Correct 241 ms 161088 KB Output is correct
37 Correct 307 ms 161592 KB Output is correct
38 Correct 169 ms 113060 KB Output is correct
39 Correct 162 ms 113500 KB Output is correct