답안 #689297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
689297 2023-01-28T06:05:11 Z zeroesandones Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
280 ms 159816 KB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define sp " "

#define all(x) (x).begin(), (x).end()
#define sc second
#define fr first
#define pb emplace_back

void solve()
{
    ll n, m;
    cin >> n >> m;

    string a[n];
    FOR(i, 0, n) {
        cin >> a[i];
    }

    ll ans = 0;

    ll row[n][m] = {};
    ll col[n][m] = {};
    FOR(i, 0, n) {
        FOR(j, 0, m) {
            row[i][j] = (a[i][j] == 'O');
            if(j) row[i][j] += row[i][j - 1];
        }
    }

    FOR(j, 0, m) {
        FOR(i, 0, n) {
            col[i][j] = (a[i][j] == 'I');
            if(i) col[i][j] += col[i - 1][j];
        }
    }

    FOR(i, 0, n) {
        FOR(j, 0, m) {
            if(a[i][j] != 'J')
                continue;
            ll O = row[i][m - 1] - row[i][j];
            ll I = col[n - 1][j] - col[i][j];
            ans += (O * I);
        }
    }

    cout << ans << nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 5 ms 3496 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 3 ms 2388 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 5 ms 4436 KB Output is correct
19 Correct 5 ms 4308 KB Output is correct
20 Correct 4 ms 4308 KB Output is correct
21 Correct 5 ms 4504 KB Output is correct
22 Correct 5 ms 4308 KB Output is correct
23 Correct 5 ms 4420 KB Output is correct
24 Correct 5 ms 4436 KB Output is correct
25 Correct 4 ms 4308 KB Output is correct
26 Correct 5 ms 4308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 5 ms 3496 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 3 ms 2388 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 5 ms 4436 KB Output is correct
19 Correct 5 ms 4308 KB Output is correct
20 Correct 4 ms 4308 KB Output is correct
21 Correct 5 ms 4504 KB Output is correct
22 Correct 5 ms 4308 KB Output is correct
23 Correct 5 ms 4420 KB Output is correct
24 Correct 5 ms 4436 KB Output is correct
25 Correct 4 ms 4308 KB Output is correct
26 Correct 5 ms 4308 KB Output is correct
27 Correct 263 ms 142568 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 13 ms 11744 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 192 ms 110984 KB Output is correct
32 Correct 277 ms 158712 KB Output is correct
33 Correct 263 ms 159340 KB Output is correct
34 Correct 225 ms 128688 KB Output is correct
35 Correct 258 ms 158700 KB Output is correct
36 Correct 260 ms 159348 KB Output is correct
37 Correct 280 ms 159816 KB Output is correct
38 Correct 182 ms 110120 KB Output is correct
39 Correct 189 ms 110536 KB Output is correct