답안 #369500

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369500 2021-02-21T18:49:37 Z Nima_Naderi Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
320 ms 159596 KB
///In the name of GOD
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 3e3 + 10;
ll H, W, ans;
ll ps[MXN][MXN], sp[MXN][MXN];
string S[MXN];
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> H >> W;
    for(int i = 1; i <= H; i ++){
        cin >> S[i], S[i] = "$" + S[i];
    }
    for(int i = 1; i <= H; i ++){
        for(int j = 1; j <= W; j ++){
            ps[i][j] = ps[i][j - 1] + (S[i][j] == 'O');
        }
    }
    for(int j = 1; j <= W; j ++){
        for(int i = 1; i <= H; i ++){
            sp[i][j] = sp[i - 1][j] + (S[i][j] == 'I');
        }
    }
    for(int i = 1; i <= H; i ++){
        for(int j = 1; j <= W; j ++){
            ll t1 = ps[i][W] - ps[i][j];
            ll t2 = sp[H][j] - sp[i][j];
            ans += t1 * t2 * (S[i][j] == 'J');
        }
    }
    cout << ans << '\n';
    return 0;
}
/*!
    HE'S AN INSTIGATOR,
    ENEMY ELIMINATOR,
    AND WHEN HE KNOCKS YOU BETTER
    YOU BETTER LET HIM IN.
*/
//! N.N
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 1388 KB Output is correct
6 Correct 1 ms 1388 KB Output is correct
7 Correct 1 ms 1388 KB Output is correct
8 Correct 1 ms 1388 KB Output is correct
9 Correct 1 ms 1388 KB Output is correct
10 Correct 1 ms 1388 KB Output is correct
11 Correct 2 ms 1388 KB Output is correct
12 Correct 1 ms 1388 KB Output is correct
13 Correct 1 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 1388 KB Output is correct
6 Correct 1 ms 1388 KB Output is correct
7 Correct 1 ms 1388 KB Output is correct
8 Correct 1 ms 1388 KB Output is correct
9 Correct 1 ms 1388 KB Output is correct
10 Correct 1 ms 1388 KB Output is correct
11 Correct 2 ms 1388 KB Output is correct
12 Correct 1 ms 1388 KB Output is correct
13 Correct 1 ms 1388 KB Output is correct
14 Correct 7 ms 7916 KB Output is correct
15 Correct 3 ms 3948 KB Output is correct
16 Correct 4 ms 4844 KB Output is correct
17 Correct 1 ms 620 KB Output is correct
18 Correct 8 ms 8940 KB Output is correct
19 Correct 8 ms 8812 KB Output is correct
20 Correct 9 ms 8684 KB Output is correct
21 Correct 8 ms 8940 KB Output is correct
22 Correct 8 ms 8684 KB Output is correct
23 Correct 8 ms 8684 KB Output is correct
24 Correct 8 ms 8940 KB Output is correct
25 Correct 8 ms 8684 KB Output is correct
26 Correct 8 ms 8684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 1388 KB Output is correct
6 Correct 1 ms 1388 KB Output is correct
7 Correct 1 ms 1388 KB Output is correct
8 Correct 1 ms 1388 KB Output is correct
9 Correct 1 ms 1388 KB Output is correct
10 Correct 1 ms 1388 KB Output is correct
11 Correct 2 ms 1388 KB Output is correct
12 Correct 1 ms 1388 KB Output is correct
13 Correct 1 ms 1388 KB Output is correct
14 Correct 7 ms 7916 KB Output is correct
15 Correct 3 ms 3948 KB Output is correct
16 Correct 4 ms 4844 KB Output is correct
17 Correct 1 ms 620 KB Output is correct
18 Correct 8 ms 8940 KB Output is correct
19 Correct 8 ms 8812 KB Output is correct
20 Correct 9 ms 8684 KB Output is correct
21 Correct 8 ms 8940 KB Output is correct
22 Correct 8 ms 8684 KB Output is correct
23 Correct 8 ms 8684 KB Output is correct
24 Correct 8 ms 8940 KB Output is correct
25 Correct 8 ms 8684 KB Output is correct
26 Correct 8 ms 8684 KB Output is correct
27 Correct 316 ms 158564 KB Output is correct
28 Correct 13 ms 19564 KB Output is correct
29 Correct 14 ms 13932 KB Output is correct
30 Correct 1 ms 876 KB Output is correct
31 Correct 228 ms 130540 KB Output is correct
32 Correct 320 ms 159340 KB Output is correct
33 Correct 316 ms 159084 KB Output is correct
34 Correct 280 ms 151464 KB Output is correct
35 Correct 311 ms 159340 KB Output is correct
36 Correct 316 ms 159048 KB Output is correct
37 Correct 309 ms 159596 KB Output is correct
38 Correct 218 ms 129772 KB Output is correct
39 Correct 221 ms 130048 KB Output is correct