#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=1e5+5;
ll h,w;
char s[3001][3001];
ll row[3001][3001];
ll col[3001][3001];
int main(){
/*freopen("tavsan.gir", "r", stdin);
freopen("tavsan.cik", "w", stdout);
*/ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> h >> w;
ref(i,1,h)ref(j,1,w)cin >> s[i][j];
ref(i,1,h){
for(ll j=w;j>=1;--j){
row[i][j]=row[i][j+1]+(s[i][j]=='O');
}
}
ref(i,1,w){
for(ll j=h;j>=1;--j){
col[j][i]=col[j+1][i]+(s[j][i]=='I');
}
}
ll ans=0;
ref(i,1,h){
ref(j,1,w){
if(s[i][j]=='J'){
ans+=row[i][j+1]*col[i+1][j];
}
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1656 KB |
Output is correct |
6 |
Correct |
3 ms |
1656 KB |
Output is correct |
7 |
Correct |
3 ms |
1528 KB |
Output is correct |
8 |
Correct |
3 ms |
1656 KB |
Output is correct |
9 |
Correct |
3 ms |
1656 KB |
Output is correct |
10 |
Correct |
3 ms |
1528 KB |
Output is correct |
11 |
Correct |
3 ms |
1656 KB |
Output is correct |
12 |
Correct |
3 ms |
1656 KB |
Output is correct |
13 |
Correct |
3 ms |
1528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1656 KB |
Output is correct |
6 |
Correct |
3 ms |
1656 KB |
Output is correct |
7 |
Correct |
3 ms |
1528 KB |
Output is correct |
8 |
Correct |
3 ms |
1656 KB |
Output is correct |
9 |
Correct |
3 ms |
1656 KB |
Output is correct |
10 |
Correct |
3 ms |
1528 KB |
Output is correct |
11 |
Correct |
3 ms |
1656 KB |
Output is correct |
12 |
Correct |
3 ms |
1656 KB |
Output is correct |
13 |
Correct |
3 ms |
1528 KB |
Output is correct |
14 |
Correct |
14 ms |
9080 KB |
Output is correct |
15 |
Correct |
6 ms |
5112 KB |
Output is correct |
16 |
Correct |
9 ms |
5368 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
9976 KB |
Output is correct |
19 |
Correct |
15 ms |
9864 KB |
Output is correct |
20 |
Correct |
15 ms |
9720 KB |
Output is correct |
21 |
Correct |
16 ms |
9976 KB |
Output is correct |
22 |
Correct |
16 ms |
9848 KB |
Output is correct |
23 |
Correct |
15 ms |
9848 KB |
Output is correct |
24 |
Correct |
17 ms |
10024 KB |
Output is correct |
25 |
Correct |
15 ms |
9848 KB |
Output is correct |
26 |
Correct |
16 ms |
9976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1656 KB |
Output is correct |
6 |
Correct |
3 ms |
1656 KB |
Output is correct |
7 |
Correct |
3 ms |
1528 KB |
Output is correct |
8 |
Correct |
3 ms |
1656 KB |
Output is correct |
9 |
Correct |
3 ms |
1656 KB |
Output is correct |
10 |
Correct |
3 ms |
1528 KB |
Output is correct |
11 |
Correct |
3 ms |
1656 KB |
Output is correct |
12 |
Correct |
3 ms |
1656 KB |
Output is correct |
13 |
Correct |
3 ms |
1528 KB |
Output is correct |
14 |
Correct |
14 ms |
9080 KB |
Output is correct |
15 |
Correct |
6 ms |
5112 KB |
Output is correct |
16 |
Correct |
9 ms |
5368 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
9976 KB |
Output is correct |
19 |
Correct |
15 ms |
9864 KB |
Output is correct |
20 |
Correct |
15 ms |
9720 KB |
Output is correct |
21 |
Correct |
16 ms |
9976 KB |
Output is correct |
22 |
Correct |
16 ms |
9848 KB |
Output is correct |
23 |
Correct |
15 ms |
9848 KB |
Output is correct |
24 |
Correct |
17 ms |
10024 KB |
Output is correct |
25 |
Correct |
15 ms |
9848 KB |
Output is correct |
26 |
Correct |
16 ms |
9976 KB |
Output is correct |
27 |
Correct |
521 ms |
158512 KB |
Output is correct |
28 |
Correct |
26 ms |
26360 KB |
Output is correct |
29 |
Correct |
26 ms |
13944 KB |
Output is correct |
30 |
Correct |
3 ms |
888 KB |
Output is correct |
31 |
Correct |
394 ms |
131256 KB |
Output is correct |
32 |
Correct |
554 ms |
158888 KB |
Output is correct |
33 |
Correct |
517 ms |
158328 KB |
Output is correct |
34 |
Correct |
490 ms |
152164 KB |
Output is correct |
35 |
Correct |
515 ms |
158760 KB |
Output is correct |
36 |
Correct |
512 ms |
158432 KB |
Output is correct |
37 |
Correct |
607 ms |
159060 KB |
Output is correct |
38 |
Correct |
368 ms |
130908 KB |
Output is correct |
39 |
Correct |
371 ms |
130812 KB |
Output is correct |