#include <bits/stdc++.h>
#define rep(a,b,c) for(int a=b; a<c; a++)
#define ll long long
using namespace std;
int main(){
ll h, w;
cin>>h>>w;
string g[h];
ll ans=0, p[h][w];
rep(i,0,h){
cin>>g[i];
rep(j,0,w){
p[i][j]=(g[i][j]=='O');
if(j) p[i][j]+=p[i][j-1];
}
}
rep(i,0,h){
rep(j,0,w){
if(g[i][j]!='I') continue;
rep(k,0,i){
if(g[k][j]=='J') ans+=p[k][w-1]-p[k][j];
}
}
}
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
71 ms |
2140 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
9 ms |
1628 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
94 ms |
2652 KB |
Output is correct |
19 |
Correct |
30 ms |
2560 KB |
Output is correct |
20 |
Correct |
68 ms |
2648 KB |
Output is correct |
21 |
Correct |
94 ms |
2908 KB |
Output is correct |
22 |
Correct |
27 ms |
2648 KB |
Output is correct |
23 |
Correct |
59 ms |
2908 KB |
Output is correct |
24 |
Correct |
66 ms |
2908 KB |
Output is correct |
25 |
Correct |
18 ms |
2776 KB |
Output is correct |
26 |
Correct |
65 ms |
3052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
71 ms |
2140 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
9 ms |
1628 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
94 ms |
2652 KB |
Output is correct |
19 |
Correct |
30 ms |
2560 KB |
Output is correct |
20 |
Correct |
68 ms |
2648 KB |
Output is correct |
21 |
Correct |
94 ms |
2908 KB |
Output is correct |
22 |
Correct |
27 ms |
2648 KB |
Output is correct |
23 |
Correct |
59 ms |
2908 KB |
Output is correct |
24 |
Correct |
66 ms |
2908 KB |
Output is correct |
25 |
Correct |
18 ms |
2776 KB |
Output is correct |
26 |
Correct |
65 ms |
3052 KB |
Output is correct |
27 |
Execution timed out |
1069 ms |
86500 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |