답안 #936937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936937 2024-03-03T04:29:45 Z detectivebowon Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
421 ms 188884 KB
#include<bits/stdc++.h>
using namespace std;
int h,w;
char space[3007][3007];
long long ans,qso[3007][3007],qsi[3007][3007];
queue<pair<int,int>> q;
int main()
{
    cin>>h>>w;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>space[i][j];
            if(space[i][j]=='J')
            {
                q.push({i,j});
            }
        }
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(space[i][j]=='I')
                qsi[i][j]=qsi[i-1][j]+1;
            else
                qsi[i][j]=qsi[i-1][j];
            if(space[i][j]=='O')
                qso[i][j]=qso[i][j-1]+1;
            else
                qso[i][j]=qso[i][j-1];
        }
    }
    while(!q.empty())
    {
        int x=q.front().first;
        int y=q.front().second;
        q.pop();
        ans+=(qsi[h][y]-qsi[x][y])*(qso[x][w]-qso[x][y]);
//        cout<<x<<" "<<y<<" "<<ans<<" "<<qsi[h][y]<<" "<<qso[x][w]<<"\n";
    }
    cout<<ans;
//    for(int i=1;i<=h;i++)
//    {
//        for(int j=1;j<=w;j++)
//        {
//            cout<<qsi[i][j]<<" ";
//        }
//        cout<<"\n";
//    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2548 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 2 ms 9052 KB Output is correct
6 Correct 2 ms 9048 KB Output is correct
7 Correct 2 ms 7004 KB Output is correct
8 Correct 2 ms 9052 KB Output is correct
9 Correct 2 ms 9052 KB Output is correct
10 Correct 1 ms 7000 KB Output is correct
11 Correct 2 ms 9048 KB Output is correct
12 Correct 2 ms 9048 KB Output is correct
13 Correct 2 ms 7004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2548 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 2 ms 9052 KB Output is correct
6 Correct 2 ms 9048 KB Output is correct
7 Correct 2 ms 7004 KB Output is correct
8 Correct 2 ms 9052 KB Output is correct
9 Correct 2 ms 9052 KB Output is correct
10 Correct 1 ms 7000 KB Output is correct
11 Correct 2 ms 9048 KB Output is correct
12 Correct 2 ms 9048 KB Output is correct
13 Correct 2 ms 7004 KB Output is correct
14 Correct 14 ms 20828 KB Output is correct
15 Correct 3 ms 16476 KB Output is correct
16 Correct 7 ms 13068 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 18 ms 21320 KB Output is correct
19 Correct 13 ms 20828 KB Output is correct
20 Correct 12 ms 21340 KB Output is correct
21 Correct 15 ms 21624 KB Output is correct
22 Correct 13 ms 21748 KB Output is correct
23 Correct 14 ms 21596 KB Output is correct
24 Correct 17 ms 21836 KB Output is correct
25 Correct 13 ms 21084 KB Output is correct
26 Correct 13 ms 21596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2548 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 2 ms 9052 KB Output is correct
6 Correct 2 ms 9048 KB Output is correct
7 Correct 2 ms 7004 KB Output is correct
8 Correct 2 ms 9052 KB Output is correct
9 Correct 2 ms 9052 KB Output is correct
10 Correct 1 ms 7000 KB Output is correct
11 Correct 2 ms 9048 KB Output is correct
12 Correct 2 ms 9048 KB Output is correct
13 Correct 2 ms 7004 KB Output is correct
14 Correct 14 ms 20828 KB Output is correct
15 Correct 3 ms 16476 KB Output is correct
16 Correct 7 ms 13068 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 18 ms 21320 KB Output is correct
19 Correct 13 ms 20828 KB Output is correct
20 Correct 12 ms 21340 KB Output is correct
21 Correct 15 ms 21624 KB Output is correct
22 Correct 13 ms 21748 KB Output is correct
23 Correct 14 ms 21596 KB Output is correct
24 Correct 17 ms 21836 KB Output is correct
25 Correct 13 ms 21084 KB Output is correct
26 Correct 13 ms 21596 KB Output is correct
27 Correct 415 ms 181692 KB Output is correct
28 Correct 12 ms 75612 KB Output is correct
29 Correct 27 ms 20560 KB Output is correct
30 Correct 2 ms 4956 KB Output is correct
31 Correct 299 ms 152072 KB Output is correct
32 Correct 378 ms 166228 KB Output is correct
33 Correct 343 ms 183556 KB Output is correct
34 Correct 332 ms 176172 KB Output is correct
35 Correct 421 ms 183056 KB Output is correct
36 Correct 406 ms 183556 KB Output is correct
37 Correct 421 ms 188884 KB Output is correct
38 Correct 248 ms 140372 KB Output is correct
39 Correct 247 ms 152272 KB Output is correct