답안 #115905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
115905 2019-06-09T15:39:37 Z dolphingarlic Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
589 ms 158976 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define FOR(i, x, y) for(int i = x; i < y; i++)
typedef long long ll;
using namespace std;

char grid[3001][3001];
ll pref1[3001][3001], pref2[3001][3001];

// Prefix sums
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    FOR(i, 1, n + 1) {
        FOR(j, 1, m + 1) {
            cin >> grid[i][j];
            pref1[i][j] = pref1[i][j - 1];
            pref2[j][i] = pref2[j][i - 1];
            if (grid[i][j] == 'O') pref1[i][j]++;
            else if (grid[i][j] == 'I') pref2[j][i]++;
        }
    }

    ll ans = 0;
    FOR(i, 1, n + 1) {
        FOR(j, 1, m + 1) {
            if (grid[i][j] == 'J') ans += (pref1[i][m] - pref1[i][j]) * (pref2[j][n] - pref2[j][i]);
        }
    }
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 3 ms 1664 KB Output is correct
6 Correct 3 ms 1536 KB Output is correct
7 Correct 3 ms 1536 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 10 ms 1536 KB Output is correct
10 Correct 4 ms 1536 KB Output is correct
11 Correct 9 ms 1664 KB Output is correct
12 Correct 3 ms 1536 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 3 ms 1664 KB Output is correct
6 Correct 3 ms 1536 KB Output is correct
7 Correct 3 ms 1536 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 10 ms 1536 KB Output is correct
10 Correct 4 ms 1536 KB Output is correct
11 Correct 9 ms 1664 KB Output is correct
12 Correct 3 ms 1536 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
14 Correct 14 ms 8576 KB Output is correct
15 Correct 5 ms 3456 KB Output is correct
16 Correct 9 ms 6372 KB Output is correct
17 Correct 3 ms 1664 KB Output is correct
18 Correct 19 ms 10112 KB Output is correct
19 Correct 15 ms 9728 KB Output is correct
20 Correct 16 ms 9828 KB Output is correct
21 Correct 18 ms 9984 KB Output is correct
22 Correct 14 ms 9728 KB Output is correct
23 Correct 16 ms 9856 KB Output is correct
24 Correct 18 ms 9976 KB Output is correct
25 Correct 15 ms 9700 KB Output is correct
26 Correct 16 ms 9856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 3 ms 1664 KB Output is correct
6 Correct 3 ms 1536 KB Output is correct
7 Correct 3 ms 1536 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 10 ms 1536 KB Output is correct
10 Correct 4 ms 1536 KB Output is correct
11 Correct 9 ms 1664 KB Output is correct
12 Correct 3 ms 1536 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
14 Correct 14 ms 8576 KB Output is correct
15 Correct 5 ms 3456 KB Output is correct
16 Correct 9 ms 6372 KB Output is correct
17 Correct 3 ms 1664 KB Output is correct
18 Correct 19 ms 10112 KB Output is correct
19 Correct 15 ms 9728 KB Output is correct
20 Correct 16 ms 9828 KB Output is correct
21 Correct 18 ms 9984 KB Output is correct
22 Correct 14 ms 9728 KB Output is correct
23 Correct 16 ms 9856 KB Output is correct
24 Correct 18 ms 9976 KB Output is correct
25 Correct 15 ms 9700 KB Output is correct
26 Correct 16 ms 9856 KB Output is correct
27 Correct 543 ms 154588 KB Output is correct
28 Correct 19 ms 16988 KB Output is correct
29 Correct 49 ms 22904 KB Output is correct
30 Correct 12 ms 10112 KB Output is correct
31 Correct 421 ms 131264 KB Output is correct
32 Correct 502 ms 158456 KB Output is correct
33 Correct 534 ms 158604 KB Output is correct
34 Correct 485 ms 142852 KB Output is correct
35 Correct 551 ms 158436 KB Output is correct
36 Correct 543 ms 158828 KB Output is correct
37 Correct 589 ms 158976 KB Output is correct
38 Correct 377 ms 130580 KB Output is correct
39 Correct 370 ms 130936 KB Output is correct