Submission #704039

# Submission time Handle Problem Language Result Execution time Memory
704039 2023-03-01T12:48:53 Z 1075508020060209tc Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
273 ms 159440 KB
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
int n;int m;
string gr[5010];
int pso[3010][3010];
int psi[3010][3010];

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

cin>>n>>m;
for(int i=1;i<=n;i++){
    cin>>gr[i];
    gr[i]="*"+gr[i];
}

for(int j=1;j<=m;j++){
    for(int i=1;i<=n;i++){
        psi[i][j]=psi[i-1][j];
        if(gr[i][j]=='I'){
            psi[i][j]++;
        }
    }
}
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        pso[i][j]=pso[i][j-1];
        if(gr[i][j]=='O'){
            pso[i][j]++;
        }
    }
}
int ans=0;
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        if(gr[i][j]!='J'){continue;}
        ans+=(pso[i][m]-pso[i][j])*(psi[n][j]-psi[i][j]);
    }
}
cout<<ans<<endl;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 484 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 480 KB Output is correct
5 Correct 1 ms 1392 KB Output is correct
6 Correct 1 ms 1384 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 484 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 480 KB Output is correct
5 Correct 1 ms 1392 KB Output is correct
6 Correct 1 ms 1384 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 6 ms 7892 KB Output is correct
15 Correct 2 ms 3924 KB Output is correct
16 Correct 3 ms 4820 KB Output is correct
17 Correct 1 ms 612 KB Output is correct
18 Correct 7 ms 8916 KB Output is correct
19 Correct 6 ms 8668 KB Output is correct
20 Correct 6 ms 8680 KB Output is correct
21 Correct 9 ms 8944 KB Output is correct
22 Correct 7 ms 8660 KB Output is correct
23 Correct 6 ms 8664 KB Output is correct
24 Correct 7 ms 8916 KB Output is correct
25 Correct 6 ms 8668 KB Output is correct
26 Correct 6 ms 8660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 484 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 480 KB Output is correct
5 Correct 1 ms 1392 KB Output is correct
6 Correct 1 ms 1384 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 6 ms 7892 KB Output is correct
15 Correct 2 ms 3924 KB Output is correct
16 Correct 3 ms 4820 KB Output is correct
17 Correct 1 ms 612 KB Output is correct
18 Correct 7 ms 8916 KB Output is correct
19 Correct 6 ms 8668 KB Output is correct
20 Correct 6 ms 8680 KB Output is correct
21 Correct 9 ms 8944 KB Output is correct
22 Correct 7 ms 8660 KB Output is correct
23 Correct 6 ms 8664 KB Output is correct
24 Correct 7 ms 8916 KB Output is correct
25 Correct 6 ms 8668 KB Output is correct
26 Correct 6 ms 8660 KB Output is correct
27 Correct 242 ms 158548 KB Output is correct
28 Correct 10 ms 19668 KB Output is correct
29 Correct 11 ms 13932 KB Output is correct
30 Correct 1 ms 852 KB Output is correct
31 Correct 190 ms 130660 KB Output is correct
32 Correct 230 ms 159436 KB Output is correct
33 Correct 213 ms 158900 KB Output is correct
34 Correct 212 ms 151384 KB Output is correct
35 Correct 215 ms 159336 KB Output is correct
36 Correct 228 ms 159008 KB Output is correct
37 Correct 273 ms 159440 KB Output is correct
38 Correct 156 ms 129756 KB Output is correct
39 Correct 154 ms 130072 KB Output is correct