답안 #1047925

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1047925 2024-08-07T17:40:08 Z vjudge1 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
143 ms 86868 KB
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int MAXN = 3e3 + 5;
 
int N, M;
char a[MAXN][MAXN];
int cO[MAXN][MAXN];
int cI[MAXN][MAXN];
 
signed main() {
#define TASK "code"
 
    if (fopen(TASK ".inp", "r")) {
        freopen(TASK ".inp", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    cin >> N >> M;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= M; j++)
            cin >> a[i][j];
    }
    for(int i = 1; i <= N; i++) {
        int cnt = 0;
        for(int j = M; j >= 1; j--) {
            if(a[i][j] == 'O')
                cnt++;
            cO[i][j] = cnt;
        }
    }
    for(int j = 1; j <= M; j++) {
        int cnt = 0;
        for(int i = N; i >= 1; i--) {
            if(a[i][j] == 'I')
                cnt++;
            cI[i][j] = cnt;
        }
    }
    i64 ans = 0;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= M; j++) {
            if(a[i][j] == 'J')
                ans += 1LL * cO[i][j] * cI[i][j];
        }
    }
    cout << ans;
    return (0 ^ 0);
}

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen(TASK ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen(TASK ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6556 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6556 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 4 ms 19036 KB Output is correct
15 Correct 1 ms 14680 KB Output is correct
16 Correct 4 ms 10840 KB Output is correct
17 Correct 0 ms 4564 KB Output is correct
18 Correct 4 ms 19036 KB Output is correct
19 Correct 4 ms 19032 KB Output is correct
20 Correct 5 ms 17120 KB Output is correct
21 Correct 4 ms 19156 KB Output is correct
22 Correct 4 ms 19036 KB Output is correct
23 Correct 4 ms 17244 KB Output is correct
24 Correct 4 ms 19272 KB Output is correct
25 Correct 4 ms 19168 KB Output is correct
26 Correct 4 ms 16988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6556 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 4 ms 19036 KB Output is correct
15 Correct 1 ms 14680 KB Output is correct
16 Correct 4 ms 10840 KB Output is correct
17 Correct 0 ms 4564 KB Output is correct
18 Correct 4 ms 19036 KB Output is correct
19 Correct 4 ms 19032 KB Output is correct
20 Correct 5 ms 17120 KB Output is correct
21 Correct 4 ms 19156 KB Output is correct
22 Correct 4 ms 19036 KB Output is correct
23 Correct 4 ms 17244 KB Output is correct
24 Correct 4 ms 19272 KB Output is correct
25 Correct 4 ms 19168 KB Output is correct
26 Correct 4 ms 16988 KB Output is correct
27 Correct 143 ms 86352 KB Output is correct
28 Correct 5 ms 65992 KB Output is correct
29 Correct 7 ms 11356 KB Output is correct
30 Correct 1 ms 4696 KB Output is correct
31 Correct 76 ms 75008 KB Output is correct
32 Correct 95 ms 86868 KB Output is correct
33 Correct 92 ms 86608 KB Output is correct
34 Correct 91 ms 85332 KB Output is correct
35 Correct 92 ms 86852 KB Output is correct
36 Correct 119 ms 86752 KB Output is correct
37 Correct 121 ms 86612 KB Output is correct
38 Correct 79 ms 75252 KB Output is correct
39 Correct 63 ms 75088 KB Output is correct