#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY LLONG_MAX
#define mod 1000000007
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 3005
#define fi first
#define se second
int O[lim][lim],I[lim][lim];
char dizi[lim][lim];
int32_t main(){
faster
int n,m;cin>>n>>m;
FOR{
string s;cin>>s;
for(int j=1;j<=m;j++){
dizi[i][j]=s[j-1];
}
}
FOR{
for(int j=1;j<=m;j++){
O[i][j]=O[i][j-1];
if(dizi[i][j]=='O')O[i][j]++;
}
}
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
I[j][i]=I[j-1][i];
if(dizi[j][i]=='I')I[j][i]++;
}
}
int cev=0;
FOR{
for(int j=1;j<=m;j++){
if(dizi[i][j]=='J')cev+=(O[i][m]-O[i][j])*(I[n][j]-I[i][j]);
//cout<<(O[i][m]-O[i][j])<<" "<<(I[n][j]-I[i][j])<<endl;
}
}
cout<<cev<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
7124 KB |
Output is correct |
6 |
Correct |
1 ms |
7004 KB |
Output is correct |
7 |
Correct |
1 ms |
7260 KB |
Output is correct |
8 |
Correct |
1 ms |
7260 KB |
Output is correct |
9 |
Correct |
1 ms |
7004 KB |
Output is correct |
10 |
Correct |
1 ms |
7260 KB |
Output is correct |
11 |
Correct |
1 ms |
7260 KB |
Output is correct |
12 |
Correct |
1 ms |
7260 KB |
Output is correct |
13 |
Correct |
1 ms |
7260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
7124 KB |
Output is correct |
6 |
Correct |
1 ms |
7004 KB |
Output is correct |
7 |
Correct |
1 ms |
7260 KB |
Output is correct |
8 |
Correct |
1 ms |
7260 KB |
Output is correct |
9 |
Correct |
1 ms |
7004 KB |
Output is correct |
10 |
Correct |
1 ms |
7260 KB |
Output is correct |
11 |
Correct |
1 ms |
7260 KB |
Output is correct |
12 |
Correct |
1 ms |
7260 KB |
Output is correct |
13 |
Correct |
1 ms |
7260 KB |
Output is correct |
14 |
Correct |
5 ms |
18524 KB |
Output is correct |
15 |
Correct |
2 ms |
14940 KB |
Output is correct |
16 |
Correct |
3 ms |
12952 KB |
Output is correct |
17 |
Correct |
1 ms |
764 KB |
Output is correct |
18 |
Correct |
6 ms |
19080 KB |
Output is correct |
19 |
Correct |
5 ms |
18780 KB |
Output is correct |
20 |
Correct |
4 ms |
18972 KB |
Output is correct |
21 |
Correct |
6 ms |
19036 KB |
Output is correct |
22 |
Correct |
4 ms |
18780 KB |
Output is correct |
23 |
Correct |
4 ms |
18776 KB |
Output is correct |
24 |
Correct |
6 ms |
19080 KB |
Output is correct |
25 |
Correct |
4 ms |
18780 KB |
Output is correct |
26 |
Correct |
5 ms |
18780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
7124 KB |
Output is correct |
6 |
Correct |
1 ms |
7004 KB |
Output is correct |
7 |
Correct |
1 ms |
7260 KB |
Output is correct |
8 |
Correct |
1 ms |
7260 KB |
Output is correct |
9 |
Correct |
1 ms |
7004 KB |
Output is correct |
10 |
Correct |
1 ms |
7260 KB |
Output is correct |
11 |
Correct |
1 ms |
7260 KB |
Output is correct |
12 |
Correct |
1 ms |
7260 KB |
Output is correct |
13 |
Correct |
1 ms |
7260 KB |
Output is correct |
14 |
Correct |
5 ms |
18524 KB |
Output is correct |
15 |
Correct |
2 ms |
14940 KB |
Output is correct |
16 |
Correct |
3 ms |
12952 KB |
Output is correct |
17 |
Correct |
1 ms |
764 KB |
Output is correct |
18 |
Correct |
6 ms |
19080 KB |
Output is correct |
19 |
Correct |
5 ms |
18780 KB |
Output is correct |
20 |
Correct |
4 ms |
18972 KB |
Output is correct |
21 |
Correct |
6 ms |
19036 KB |
Output is correct |
22 |
Correct |
4 ms |
18780 KB |
Output is correct |
23 |
Correct |
4 ms |
18776 KB |
Output is correct |
24 |
Correct |
6 ms |
19080 KB |
Output is correct |
25 |
Correct |
4 ms |
18780 KB |
Output is correct |
26 |
Correct |
5 ms |
18780 KB |
Output is correct |
27 |
Correct |
111 ms |
158720 KB |
Output is correct |
28 |
Correct |
10 ms |
72028 KB |
Output is correct |
29 |
Correct |
5 ms |
17884 KB |
Output is correct |
30 |
Correct |
1 ms |
776 KB |
Output is correct |
31 |
Correct |
79 ms |
134164 KB |
Output is correct |
32 |
Correct |
63 ms |
159224 KB |
Output is correct |
33 |
Correct |
61 ms |
158716 KB |
Output is correct |
34 |
Correct |
101 ms |
154000 KB |
Output is correct |
35 |
Correct |
61 ms |
159124 KB |
Output is correct |
36 |
Correct |
59 ms |
158732 KB |
Output is correct |
37 |
Correct |
111 ms |
159244 KB |
Output is correct |
38 |
Correct |
49 ms |
133972 KB |
Output is correct |
39 |
Correct |
48 ms |
134132 KB |
Output is correct |