답안 #367321

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
367321 2021-02-16T21:06:52 Z piddddgy Bitaro the Brave (JOI19_ho_t1) C++11
100 / 100
353 ms 229740 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define cerr if(false) cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define ld long double
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(x) (x).begin(), (x).end()

const int maxn = 3005;
int n, m;

char a[maxn][maxn];

int psa[5][maxn][maxn];

int query(int c, int i, int j, int ii, int jj) {
    cerr << c << " " << i << " " << j << " " << ii << " " << jj << endl;
    return psa[c][ii][jj] - psa[c][ii][j-1] - psa[c][i-1][jj] + psa[c][i-1][j-1];
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m;

    for(int i = 1; i <= n; i++) {
        string s;
        cin >> s;

        for(int j = 1; j <= m; j++) {
            a[i][j] = s[j-1];
            if(a[i][j] == 'J') psa[1][i][j]++;
            else if(a[i][j] == 'O') psa[2][i][j]++;
            else if(a[i][j] == 'I') psa[3][i][j]++;
        }
    }

    for(int c = 1; c <= 3; c++) {
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= m; j++) {
                psa[c][i][j] += psa[c][i-1][j] + psa[c][i][j-1] - psa[c][i-1][j-1];
            }
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(a[i][j] == 'J') {
                cerr << "passing in " << i << " " << j << " " << n << " " << j << endl;
                int ocnt = query(2, i, j, i, m);
                int icnt = query(3, i, j, n, j);

                ans += ocnt*icnt;
            }
        }
    }

    cout << ans << endl;
}

/*



Did you read the bounds?
Did you make typos?
Are there edge cases (N=1?)
Are array sizes proper?
Integer overflow?
DS reset properly between test cases?
Is using long longs causing TLE?
Are you using floating points?
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 2156 KB Output is correct
6 Correct 2 ms 2028 KB Output is correct
7 Correct 2 ms 1900 KB Output is correct
8 Correct 2 ms 2156 KB Output is correct
9 Correct 2 ms 2028 KB Output is correct
10 Correct 2 ms 1900 KB Output is correct
11 Correct 2 ms 2156 KB Output is correct
12 Correct 2 ms 2028 KB Output is correct
13 Correct 2 ms 1900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 2156 KB Output is correct
6 Correct 2 ms 2028 KB Output is correct
7 Correct 2 ms 1900 KB Output is correct
8 Correct 2 ms 2156 KB Output is correct
9 Correct 2 ms 2028 KB Output is correct
10 Correct 2 ms 1900 KB Output is correct
11 Correct 2 ms 2156 KB Output is correct
12 Correct 2 ms 2028 KB Output is correct
13 Correct 2 ms 1900 KB Output is correct
14 Correct 12 ms 12524 KB Output is correct
15 Correct 4 ms 6892 KB Output is correct
16 Correct 6 ms 7404 KB Output is correct
17 Correct 1 ms 620 KB Output is correct
18 Correct 15 ms 14060 KB Output is correct
19 Correct 12 ms 13804 KB Output is correct
20 Correct 12 ms 13676 KB Output is correct
21 Correct 14 ms 14060 KB Output is correct
22 Correct 12 ms 13824 KB Output is correct
23 Correct 13 ms 13676 KB Output is correct
24 Correct 14 ms 14060 KB Output is correct
25 Correct 12 ms 13804 KB Output is correct
26 Correct 14 ms 13676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 2156 KB Output is correct
6 Correct 2 ms 2028 KB Output is correct
7 Correct 2 ms 1900 KB Output is correct
8 Correct 2 ms 2156 KB Output is correct
9 Correct 2 ms 2028 KB Output is correct
10 Correct 2 ms 1900 KB Output is correct
11 Correct 2 ms 2156 KB Output is correct
12 Correct 2 ms 2028 KB Output is correct
13 Correct 2 ms 1900 KB Output is correct
14 Correct 12 ms 12524 KB Output is correct
15 Correct 4 ms 6892 KB Output is correct
16 Correct 6 ms 7404 KB Output is correct
17 Correct 1 ms 620 KB Output is correct
18 Correct 15 ms 14060 KB Output is correct
19 Correct 12 ms 13804 KB Output is correct
20 Correct 12 ms 13676 KB Output is correct
21 Correct 14 ms 14060 KB Output is correct
22 Correct 12 ms 13824 KB Output is correct
23 Correct 13 ms 13676 KB Output is correct
24 Correct 14 ms 14060 KB Output is correct
25 Correct 12 ms 13804 KB Output is correct
26 Correct 14 ms 13676 KB Output is correct
27 Correct 330 ms 229328 KB Output is correct
28 Correct 22 ms 35948 KB Output is correct
29 Correct 21 ms 20076 KB Output is correct
30 Correct 1 ms 1132 KB Output is correct
31 Correct 252 ms 190316 KB Output is correct
32 Correct 286 ms 229612 KB Output is correct
33 Correct 254 ms 228972 KB Output is correct
34 Correct 300 ms 220908 KB Output is correct
35 Correct 270 ms 229740 KB Output is correct
36 Correct 262 ms 228972 KB Output is correct
37 Correct 353 ms 229740 KB Output is correct
38 Correct 206 ms 189460 KB Output is correct
39 Correct 201 ms 189564 KB Output is correct