답안 #818714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
818714 2023-08-10T06:28:11 Z vjudge1 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
263 ms 200876 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MX = 3e3 + 5;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h, w;
    cin >> h >> w;
    vector<vector<ll>> Ohere(MX, vector<ll>(MX, 0));
    vector<vector<ll>> Ihere(MX, vector<ll>(MX, 0));
    char tmp;
    queue<pair<ll, ll>> q;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            cin >> tmp;
            if (tmp == 'J')
            {
                q.push({i, j});
            }
            else if (tmp == 'O')
            {
                Ohere[i][j]++;
            }
            else
            {
                Ihere[i][j]++;
            }
            Ohere[i][j] += Ohere[i][j - 1];
            Ihere[i][j] += Ihere[i - 1][j];
        }
    }
    ll ans = 0;
    while (!q.empty())
    {
        ll x = q.front().first;
        ll y = q.front().second;
        q.pop();
        ll Othere = Ohere[x][w] - Ohere[x][y - 1];
        ll Ithere = Ihere[h][y] - Ihere[x - 1][y];

        ans += Othere * Ithere;
    }
    // for (int i = 1; i <= h; i++)
    // {
    //     for (int j = 1; j <= w; j++)
    //     {
    //         cout << Ohere[i][j];
    //     }
    //     cout << "\n";
    // }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 141876 KB Output is correct
2 Correct 49 ms 141836 KB Output is correct
3 Correct 51 ms 141880 KB Output is correct
4 Correct 53 ms 141776 KB Output is correct
5 Correct 50 ms 141840 KB Output is correct
6 Correct 53 ms 141892 KB Output is correct
7 Correct 52 ms 141892 KB Output is correct
8 Correct 51 ms 141816 KB Output is correct
9 Correct 52 ms 141800 KB Output is correct
10 Correct 49 ms 141900 KB Output is correct
11 Correct 50 ms 141872 KB Output is correct
12 Correct 49 ms 141776 KB Output is correct
13 Correct 48 ms 141860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 141876 KB Output is correct
2 Correct 49 ms 141836 KB Output is correct
3 Correct 51 ms 141880 KB Output is correct
4 Correct 53 ms 141776 KB Output is correct
5 Correct 50 ms 141840 KB Output is correct
6 Correct 53 ms 141892 KB Output is correct
7 Correct 52 ms 141892 KB Output is correct
8 Correct 51 ms 141816 KB Output is correct
9 Correct 52 ms 141800 KB Output is correct
10 Correct 49 ms 141900 KB Output is correct
11 Correct 50 ms 141872 KB Output is correct
12 Correct 49 ms 141776 KB Output is correct
13 Correct 48 ms 141860 KB Output is correct
14 Correct 54 ms 142900 KB Output is correct
15 Correct 50 ms 141820 KB Output is correct
16 Correct 52 ms 142564 KB Output is correct
17 Correct 49 ms 141876 KB Output is correct
18 Correct 60 ms 143140 KB Output is correct
19 Correct 51 ms 142112 KB Output is correct
20 Correct 52 ms 143120 KB Output is correct
21 Correct 54 ms 143128 KB Output is correct
22 Correct 53 ms 143204 KB Output is correct
23 Correct 51 ms 143188 KB Output is correct
24 Correct 58 ms 143480 KB Output is correct
25 Correct 53 ms 142224 KB Output is correct
26 Correct 52 ms 143156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 141876 KB Output is correct
2 Correct 49 ms 141836 KB Output is correct
3 Correct 51 ms 141880 KB Output is correct
4 Correct 53 ms 141776 KB Output is correct
5 Correct 50 ms 141840 KB Output is correct
6 Correct 53 ms 141892 KB Output is correct
7 Correct 52 ms 141892 KB Output is correct
8 Correct 51 ms 141816 KB Output is correct
9 Correct 52 ms 141800 KB Output is correct
10 Correct 49 ms 141900 KB Output is correct
11 Correct 50 ms 141872 KB Output is correct
12 Correct 49 ms 141776 KB Output is correct
13 Correct 48 ms 141860 KB Output is correct
14 Correct 54 ms 142900 KB Output is correct
15 Correct 50 ms 141820 KB Output is correct
16 Correct 52 ms 142564 KB Output is correct
17 Correct 49 ms 141876 KB Output is correct
18 Correct 60 ms 143140 KB Output is correct
19 Correct 51 ms 142112 KB Output is correct
20 Correct 52 ms 143120 KB Output is correct
21 Correct 54 ms 143128 KB Output is correct
22 Correct 53 ms 143204 KB Output is correct
23 Correct 51 ms 143188 KB Output is correct
24 Correct 58 ms 143480 KB Output is correct
25 Correct 53 ms 142224 KB Output is correct
26 Correct 52 ms 143156 KB Output is correct
27 Correct 251 ms 187848 KB Output is correct
28 Correct 59 ms 141892 KB Output is correct
29 Correct 61 ms 145596 KB Output is correct
30 Correct 52 ms 141920 KB Output is correct
31 Correct 198 ms 175640 KB Output is correct
32 Correct 180 ms 155924 KB Output is correct
33 Correct 177 ms 190896 KB Output is correct
34 Correct 224 ms 180940 KB Output is correct
35 Correct 202 ms 189552 KB Output is correct
36 Correct 176 ms 190828 KB Output is correct
37 Correct 263 ms 200876 KB Output is correct
38 Correct 139 ms 152320 KB Output is correct
39 Correct 140 ms 175780 KB Output is correct