#include<bits/stdc++.h>
#define F first
#define S second
#define MAX 3005
#define oo 1e18
#define mod 1000000007
#define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0);
using namespace std;
typedef long long ll;
#define pll pair<ll , ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vpll vector<pll>
ll o[MAX][MAX],t[MAX][MAX],n,m;
string s[MAX];
int main(){
fast_in
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>s[i];
for(int j=m-1;j>=0;j--){
o[i][j]=o[i][j+1];
if(s[i][j]=='O')o[i][j]++;
}
}
for(int j=m-1;j>=0;j--){
for(int i=n-1;i>=0;i--){
t[i][j]=t[i+1][j];
if(s[i][j]=='I')t[i][j]++;
}
}ll r=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(s[i][j]=='J'){
r+=o[i][j]*t[i][j];
}
}
}cout<<r;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
496 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
3120 KB |
Output is correct |
6 |
Correct |
1 ms |
2908 KB |
Output is correct |
7 |
Correct |
1 ms |
1336 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
1 ms |
2904 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
2 ms |
2908 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
496 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
3120 KB |
Output is correct |
6 |
Correct |
1 ms |
2908 KB |
Output is correct |
7 |
Correct |
1 ms |
1336 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
1 ms |
2904 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
2 ms |
2908 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
14 |
Correct |
6 ms |
15192 KB |
Output is correct |
15 |
Correct |
2 ms |
10588 KB |
Output is correct |
16 |
Correct |
3 ms |
7512 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
7 ms |
15708 KB |
Output is correct |
19 |
Correct |
5 ms |
15448 KB |
Output is correct |
20 |
Correct |
6 ms |
15452 KB |
Output is correct |
21 |
Correct |
7 ms |
15708 KB |
Output is correct |
22 |
Correct |
5 ms |
15708 KB |
Output is correct |
23 |
Correct |
5 ms |
15452 KB |
Output is correct |
24 |
Correct |
7 ms |
15636 KB |
Output is correct |
25 |
Correct |
5 ms |
15452 KB |
Output is correct |
26 |
Correct |
7 ms |
15528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
496 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
3120 KB |
Output is correct |
6 |
Correct |
1 ms |
2908 KB |
Output is correct |
7 |
Correct |
1 ms |
1336 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
1 ms |
2904 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
2 ms |
2908 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
14 |
Correct |
6 ms |
15192 KB |
Output is correct |
15 |
Correct |
2 ms |
10588 KB |
Output is correct |
16 |
Correct |
3 ms |
7512 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
7 ms |
15708 KB |
Output is correct |
19 |
Correct |
5 ms |
15448 KB |
Output is correct |
20 |
Correct |
6 ms |
15452 KB |
Output is correct |
21 |
Correct |
7 ms |
15708 KB |
Output is correct |
22 |
Correct |
5 ms |
15708 KB |
Output is correct |
23 |
Correct |
5 ms |
15452 KB |
Output is correct |
24 |
Correct |
7 ms |
15636 KB |
Output is correct |
25 |
Correct |
5 ms |
15452 KB |
Output is correct |
26 |
Correct |
7 ms |
15528 KB |
Output is correct |
27 |
Correct |
207 ms |
158968 KB |
Output is correct |
28 |
Correct |
10 ms |
63580 KB |
Output is correct |
29 |
Correct |
11 ms |
14056 KB |
Output is correct |
30 |
Correct |
1 ms |
856 KB |
Output is correct |
31 |
Correct |
147 ms |
130900 KB |
Output is correct |
32 |
Correct |
181 ms |
159824 KB |
Output is correct |
33 |
Correct |
172 ms |
159572 KB |
Output is correct |
34 |
Correct |
169 ms |
151636 KB |
Output is correct |
35 |
Correct |
171 ms |
160180 KB |
Output is correct |
36 |
Correct |
165 ms |
159640 KB |
Output is correct |
37 |
Correct |
216 ms |
159988 KB |
Output is correct |
38 |
Correct |
119 ms |
130440 KB |
Output is correct |
39 |
Correct |
120 ms |
130204 KB |
Output is correct |