답안 #529443

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
529443 2022-02-23T02:45:09 Z leu_naut Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
409 ms 109640 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 3e3;
const int MOD = 1e9 + 7;
const ll oo = 1e18;


int n,m;
char a[N + 5][N + 5];
int bit[2][N + 5][N + 5];
vector <int> cntJ[N + 5];

void upd(int x, int tp, int z)
{
    for (; x <= N; x += x & -x) bit[z][tp][x]++;
}

int get(int x, int tp, int z)
{
    int ans = 0;
    while (x > 0) {
        ans += bit[z][tp][x];
        x -= x & -x;
    }
    return ans;
}

int main()
{
    ios_base::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] == 'O') upd(j,i,0);
            else if (a[i][j] == 'I') upd(i,j,1);
            else cntJ[j].push_back(i);
        }
    }

    ll ans = 0;

    for (int j = 1; j <= m; ++j) {
        for (int i : cntJ[j]) {
            ll tmpI = get(n,j,1) - get(i,j,1);
            ll tmpO = get(m,i,0) - get(j,i,0);
            //cout << j << ' ' << i << ' ' << tmpI << ' ' << tmpO << '\n';
            ans = ans + tmpI * tmpO;
        }
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 388 KB Output is correct
3 Correct 1 ms 380 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 2 ms 3084 KB Output is correct
6 Correct 2 ms 2692 KB Output is correct
7 Correct 2 ms 2820 KB Output is correct
8 Correct 2 ms 3012 KB Output is correct
9 Correct 2 ms 2684 KB Output is correct
10 Correct 2 ms 2892 KB Output is correct
11 Correct 2 ms 3020 KB Output is correct
12 Correct 2 ms 2700 KB Output is correct
13 Correct 2 ms 2892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 388 KB Output is correct
3 Correct 1 ms 380 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 2 ms 3084 KB Output is correct
6 Correct 2 ms 2692 KB Output is correct
7 Correct 2 ms 2820 KB Output is correct
8 Correct 2 ms 3012 KB Output is correct
9 Correct 2 ms 2684 KB Output is correct
10 Correct 2 ms 2892 KB Output is correct
11 Correct 2 ms 3020 KB Output is correct
12 Correct 2 ms 2700 KB Output is correct
13 Correct 2 ms 2892 KB Output is correct
14 Correct 11 ms 12796 KB Output is correct
15 Correct 3 ms 6016 KB Output is correct
16 Correct 7 ms 10360 KB Output is correct
17 Correct 2 ms 3840 KB Output is correct
18 Correct 13 ms 14476 KB Output is correct
19 Correct 11 ms 13680 KB Output is correct
20 Correct 10 ms 13016 KB Output is correct
21 Correct 13 ms 14424 KB Output is correct
22 Correct 11 ms 14020 KB Output is correct
23 Correct 10 ms 12940 KB Output is correct
24 Correct 13 ms 14404 KB Output is correct
25 Correct 10 ms 13696 KB Output is correct
26 Correct 10 ms 12940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 388 KB Output is correct
3 Correct 1 ms 380 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 2 ms 3084 KB Output is correct
6 Correct 2 ms 2692 KB Output is correct
7 Correct 2 ms 2820 KB Output is correct
8 Correct 2 ms 3012 KB Output is correct
9 Correct 2 ms 2684 KB Output is correct
10 Correct 2 ms 2892 KB Output is correct
11 Correct 2 ms 3020 KB Output is correct
12 Correct 2 ms 2700 KB Output is correct
13 Correct 2 ms 2892 KB Output is correct
14 Correct 11 ms 12796 KB Output is correct
15 Correct 3 ms 6016 KB Output is correct
16 Correct 7 ms 10360 KB Output is correct
17 Correct 2 ms 3840 KB Output is correct
18 Correct 13 ms 14476 KB Output is correct
19 Correct 11 ms 13680 KB Output is correct
20 Correct 10 ms 13016 KB Output is correct
21 Correct 13 ms 14424 KB Output is correct
22 Correct 11 ms 14020 KB Output is correct
23 Correct 10 ms 12940 KB Output is correct
24 Correct 13 ms 14404 KB Output is correct
25 Correct 10 ms 13696 KB Output is correct
26 Correct 10 ms 12940 KB Output is correct
27 Correct 349 ms 95796 KB Output is correct
28 Correct 13 ms 31228 KB Output is correct
29 Correct 29 ms 35448 KB Output is correct
30 Correct 12 ms 27136 KB Output is correct
31 Correct 243 ms 81524 KB Output is correct
32 Correct 239 ms 88108 KB Output is correct
33 Correct 251 ms 76152 KB Output is correct
34 Correct 295 ms 87236 KB Output is correct
35 Correct 330 ms 100468 KB Output is correct
36 Correct 255 ms 76184 KB Output is correct
37 Correct 409 ms 109640 KB Output is correct
38 Correct 143 ms 73412 KB Output is correct
39 Correct 171 ms 61988 KB Output is correct