답안 #553268

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
553268 2022-04-25T10:01:19 Z sandry24 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
428 ms 88788 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second

void solve(){
    int n, m;
    cin >> n >> m;
    vector<vector<char>> grid(n, vector<char>(m));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++)
            cin >> grid[i][j];
    }
    vector<vi> i_down(n+1, vi(m+1)), o_right(n+1, vi(m+1));
    for(int i = n-1; i >= 0; i--){
        for(int j = 0; j < m; j++){
            i_down[i][j] = i_down[i+1][j];
            if(grid[i][j] == 'I')
                i_down[i][j]++;
        }
    }
    for(int j = m-1; j >= 0; j--){
        for(int i = 0; i < n; i++){
            o_right[i][j] = o_right[i][j+1];
            if(grid[i][j] == 'O')
                o_right[i][j]++;
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(grid[i][j] == 'J')
                ans += o_right[i][j]*i_down[i][j];
        }
    }
    cout << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 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 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 10 ms 2132 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 5 ms 1620 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 9 ms 2768 KB Output is correct
19 Correct 6 ms 2644 KB Output is correct
20 Correct 7 ms 2772 KB Output is correct
21 Correct 11 ms 2744 KB Output is correct
22 Correct 6 ms 2644 KB Output is correct
23 Correct 6 ms 2772 KB Output is correct
24 Correct 9 ms 2772 KB Output is correct
25 Correct 7 ms 2728 KB Output is correct
26 Correct 8 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 10 ms 2132 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 5 ms 1620 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 9 ms 2768 KB Output is correct
19 Correct 6 ms 2644 KB Output is correct
20 Correct 7 ms 2772 KB Output is correct
21 Correct 11 ms 2744 KB Output is correct
22 Correct 6 ms 2644 KB Output is correct
23 Correct 6 ms 2772 KB Output is correct
24 Correct 9 ms 2772 KB Output is correct
25 Correct 7 ms 2728 KB Output is correct
26 Correct 8 ms 2772 KB Output is correct
27 Correct 416 ms 83832 KB Output is correct
28 Correct 2 ms 852 KB Output is correct
29 Correct 17 ms 6576 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 301 ms 61776 KB Output is correct
32 Correct 355 ms 88168 KB Output is correct
33 Correct 401 ms 88448 KB Output is correct
34 Correct 347 ms 71604 KB Output is correct
35 Correct 393 ms 88256 KB Output is correct
36 Correct 366 ms 88532 KB Output is correct
37 Correct 428 ms 88788 KB Output is correct
38 Correct 228 ms 61256 KB Output is correct
39 Correct 221 ms 61492 KB Output is correct