답안 #990074

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990074 2024-05-29T13:20:46 Z coftochka Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
224 ms 92052 KB
#include <iostream>
#include <cstring>

using namespace std;

const int N = 3030;
int O[N][N];
int I[N][N];
string s[N];
int n, m;


void input(){
    cin >> n >> m;
    for (int i = 0; i < n; ++i){
        cin >> s[i];
    }
    
}

void preprocess(){
    for (int i = 0; i < n; ++i){
        O[i][m] = 0;
        for (int j = m - 1; j >= 0; --j){
            O[i][j] = O[i][j + 1];
            if (s[i][j] == 'O'){
                ++O[i][j];
            }
        }
    }
    for (int j = 0; j < m; ++j){
        I[n][j] = 0;
        for (int i = n - 1; i >= 0; --i){
            I[i][j] = I[i + 1][j];
            if (s[i][j] == 'I'){
                ++I[i][j];
            }
        }
    }
}

long long solve(){
    long long ans = 0;
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < m; ++j){
            if (s[i][j] == 'J'){
                ans += O[i][j] * I[i][j];
            }
        }
    }
    return ans;
}

int main(){
    input();
    preprocess();
    cout << solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 6 ms 15360 KB Output is correct
15 Correct 1 ms 12892 KB Output is correct
16 Correct 3 ms 9052 KB Output is correct
17 Correct 1 ms 4700 KB Output is correct
18 Correct 8 ms 15452 KB Output is correct
19 Correct 6 ms 15196 KB Output is correct
20 Correct 6 ms 15452 KB Output is correct
21 Correct 8 ms 15456 KB Output is correct
22 Correct 6 ms 15364 KB Output is correct
23 Correct 6 ms 15456 KB Output is correct
24 Correct 7 ms 15612 KB Output is correct
25 Correct 6 ms 15292 KB Output is correct
26 Correct 6 ms 15456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 4700 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 6 ms 15360 KB Output is correct
15 Correct 1 ms 12892 KB Output is correct
16 Correct 3 ms 9052 KB Output is correct
17 Correct 1 ms 4700 KB Output is correct
18 Correct 8 ms 15452 KB Output is correct
19 Correct 6 ms 15196 KB Output is correct
20 Correct 6 ms 15452 KB Output is correct
21 Correct 8 ms 15456 KB Output is correct
22 Correct 6 ms 15364 KB Output is correct
23 Correct 6 ms 15456 KB Output is correct
24 Correct 7 ms 15612 KB Output is correct
25 Correct 6 ms 15292 KB Output is correct
26 Correct 6 ms 15456 KB Output is correct
27 Correct 217 ms 91732 KB Output is correct
28 Correct 6 ms 57952 KB Output is correct
29 Correct 11 ms 10452 KB Output is correct
30 Correct 1 ms 4700 KB Output is correct
31 Correct 158 ms 77708 KB Output is correct
32 Correct 177 ms 92052 KB Output is correct
33 Correct 170 ms 91792 KB Output is correct
34 Correct 180 ms 88720 KB Output is correct
35 Correct 171 ms 91988 KB Output is correct
36 Correct 176 ms 91948 KB Output is correct
37 Correct 224 ms 91984 KB Output is correct
38 Correct 134 ms 77656 KB Output is correct
39 Correct 116 ms 77648 KB Output is correct