답안 #743465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743465 2023-05-17T12:03:57 Z AndrijaM Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
552 ms 216344 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    long long n,m;
    cin>>n>>m;
    char mat[n][m];
    long long ci[n];
    long long cj[m];
    long long posi[n][m];
    long long posj[m][n];
    memset(posi,0,sizeof posi);
    memset(posj,0,sizeof posj);
    memset(ci,0,sizeof ci);
    memset(cj,0,sizeof cj);
    vector<pair<long long,long long>>v;
    for(long long i=0;i<n;i++)
    {
        for(long long j=0;j<m;j++)
        {
            cin>>mat[i][j];
            if(j>0)
            {
                posi[i][j]=posi[i][j-1];
            }
            if(i>0)
            {
                posj[j][i]=posj[j][i-1];
            }
            if(mat[i][j]=='O')
            {
                ci[i]++;
                posi[i][j]++;
            }
            if(mat[i][j]=='I')
            {
                cj[j]++;
                posj[j][i]++;
            }
            if(mat[i][j]=='J')
            {
                v.push_back({i,j});
            }
        }
    }
    long long ans=0;
    for(auto idx:v)
    {
        long long a=idx.first;
        long long b=idx.second;
        if(ci[a]-posi[a][b]>0 && cj[b]-posj[b][a]>0)
        ans+=(ci[a]-posi[a][b])*(cj[b]-posj[b][a]);
    }
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 584 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 448 KB Output is correct
13 Correct 1 ms 468 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 1 ms 316 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 584 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 448 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 10 ms 4812 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 7 ms 3668 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 15 ms 6864 KB Output is correct
19 Correct 12 ms 5208 KB Output is correct
20 Correct 11 ms 6764 KB Output is correct
21 Correct 14 ms 6856 KB Output is correct
22 Correct 12 ms 6732 KB Output is correct
23 Correct 13 ms 6768 KB Output is correct
24 Correct 15 ms 6864 KB Output is correct
25 Correct 9 ms 5204 KB Output is correct
26 Correct 14 ms 6736 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 1 ms 316 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 584 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 448 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 10 ms 4812 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 7 ms 3668 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 15 ms 6864 KB Output is correct
19 Correct 12 ms 5208 KB Output is correct
20 Correct 11 ms 6764 KB Output is correct
21 Correct 14 ms 6856 KB Output is correct
22 Correct 12 ms 6732 KB Output is correct
23 Correct 13 ms 6768 KB Output is correct
24 Correct 15 ms 6864 KB Output is correct
25 Correct 9 ms 5204 KB Output is correct
26 Correct 14 ms 6736 KB Output is correct
27 Correct 546 ms 208564 KB Output is correct
28 Correct 2 ms 1108 KB Output is correct
29 Correct 26 ms 15928 KB Output is correct
30 Correct 2 ms 972 KB Output is correct
31 Correct 366 ms 137808 KB Output is correct
32 Correct 381 ms 166316 KB Output is correct
33 Correct 539 ms 215852 KB Output is correct
34 Correct 453 ms 187744 KB Output is correct
35 Correct 499 ms 215604 KB Output is correct
36 Correct 551 ms 216020 KB Output is correct
37 Correct 552 ms 216344 KB Output is correct
38 Correct 272 ms 120772 KB Output is correct
39 Correct 305 ms 137460 KB Output is correct