답안 #1038532

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1038532 2024-07-29T22:31:53 Z MrPavlito Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
216 ms 220872 KB
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
#define endl "\n"
#define pii pair<int,int>

using namespace std;

const int MAXN = 1e5+5;
const int mod7 = 1e9+7;
const long long inf = 1e18;

signed main()
{
    ios_base::sync_with_stdio(false),cin.tie(0), cout.tie(0);
    int tt=1;
    //cin >> tt;
    while(tt--)
    {
        int n,m;
        cin >> n >> m;
        vector<vector<int>> mat(n+1,vector<int>(m+1,0));
        vector<vector<int>> prefh(n+1,vector<int>(m+1,0));
        vector<vector<int>> prefv(n+1,vector<int>(m+1,0));
        for(int i=1; i<=n; i++)
        {
            string s;cin >> s;
            for(int j=1; j<=m;j++)
            {
                mat[i][j] = s[j-1];
                if(mat[i][j] == 'I')prefv[i][j] = 1;
                else if(mat[i][j] == 'O')prefh[i][j] = 1;
            }
        }
        for(int i=1; i<=n;i++)for(int j=1; j<=m; j++)prefh[i][j] += prefh[i][j-1];
        for(int i=1; i<=m;i++)for(int j=1; j<=n; j++)prefv[j][i] += prefv[j-1][i];
        long long rez = 0;
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=m; j++)
            {
                if(mat[i][j] != 'J')continue;
                rez+= (prefh[i][m]-prefh[i][j])*(prefv[n][j]-prefv[i][j]);
            }
        }
        cout << rez << endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 456 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 456 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 5 ms 5212 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 2 ms 3428 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 6 ms 6656 KB Output is correct
19 Correct 3 ms 6236 KB Output is correct
20 Correct 4 ms 6492 KB Output is correct
21 Correct 6 ms 6504 KB Output is correct
22 Correct 4 ms 6232 KB Output is correct
23 Correct 4 ms 6404 KB Output is correct
24 Correct 5 ms 6492 KB Output is correct
25 Correct 4 ms 6236 KB Output is correct
26 Correct 5 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 456 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 5 ms 5212 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 2 ms 3428 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 6 ms 6656 KB Output is correct
19 Correct 3 ms 6236 KB Output is correct
20 Correct 4 ms 6492 KB Output is correct
21 Correct 6 ms 6504 KB Output is correct
22 Correct 4 ms 6232 KB Output is correct
23 Correct 4 ms 6404 KB Output is correct
24 Correct 5 ms 6492 KB Output is correct
25 Correct 4 ms 6236 KB Output is correct
26 Correct 5 ms 6492 KB Output is correct
27 Correct 206 ms 208728 KB Output is correct
28 Correct 1 ms 1368 KB Output is correct
29 Correct 10 ms 16396 KB Output is correct
30 Correct 1 ms 860 KB Output is correct
31 Correct 151 ms 153564 KB Output is correct
32 Correct 177 ms 219388 KB Output is correct
33 Correct 160 ms 220204 KB Output is correct
34 Correct 176 ms 178204 KB Output is correct
35 Correct 164 ms 219712 KB Output is correct
36 Correct 166 ms 220100 KB Output is correct
37 Correct 216 ms 220872 KB Output is correct
38 Correct 106 ms 152400 KB Output is correct
39 Correct 103 ms 152912 KB Output is correct