#include <bits/stdc++.h>
using namespace std;
int a[3009][3009];
int b[3009][3009];
int c[3009][3009];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen(".INP","r",stdin);
// freopen(".OUT","w",stdout);
int n,m;
cin>>n>>m;
for (int i=1;i<=n;i++){
string s;
cin>>s;
for (int j=1;j<=m;j++){
if (s[j-1]=='J')a[i][j]=1;
else if (s[j-1]=='O')a[i][j]=2;
else a[i][j]=3;
}
}
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
b[i][j]=b[i][j-1];
if (a[i][j]==2)b[i][j]++;
}
}
for (int j=1;j<=m;j++){
for (int i=1;i<=n;i++){
c[i][j]=c[i-1][j];
if (a[i][j]==3)c[i][j]++;
}
}
long long ans=0;
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
if (a[i][j]==1)ans=ans+(b[i][m]-b[i][j])*(c[n][j]-c[i][j]);
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
456 KB |
Output is correct |
5 |
Correct |
1 ms |
1620 KB |
Output is correct |
6 |
Correct |
1 ms |
1608 KB |
Output is correct |
7 |
Correct |
1 ms |
1492 KB |
Output is correct |
8 |
Correct |
1 ms |
1620 KB |
Output is correct |
9 |
Correct |
1 ms |
1620 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
1 ms |
1620 KB |
Output is correct |
12 |
Correct |
1 ms |
1620 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
456 KB |
Output is correct |
5 |
Correct |
1 ms |
1620 KB |
Output is correct |
6 |
Correct |
1 ms |
1608 KB |
Output is correct |
7 |
Correct |
1 ms |
1492 KB |
Output is correct |
8 |
Correct |
1 ms |
1620 KB |
Output is correct |
9 |
Correct |
1 ms |
1620 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
1 ms |
1620 KB |
Output is correct |
12 |
Correct |
1 ms |
1620 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
9 ms |
8788 KB |
Output is correct |
15 |
Correct |
3 ms |
5448 KB |
Output is correct |
16 |
Correct |
4 ms |
5076 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
12 ms |
9584 KB |
Output is correct |
19 |
Correct |
8 ms |
9368 KB |
Output is correct |
20 |
Correct |
7 ms |
9320 KB |
Output is correct |
21 |
Correct |
12 ms |
9504 KB |
Output is correct |
22 |
Correct |
7 ms |
9368 KB |
Output is correct |
23 |
Correct |
7 ms |
9300 KB |
Output is correct |
24 |
Correct |
10 ms |
9556 KB |
Output is correct |
25 |
Correct |
7 ms |
9428 KB |
Output is correct |
26 |
Correct |
7 ms |
9240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
456 KB |
Output is correct |
5 |
Correct |
1 ms |
1620 KB |
Output is correct |
6 |
Correct |
1 ms |
1608 KB |
Output is correct |
7 |
Correct |
1 ms |
1492 KB |
Output is correct |
8 |
Correct |
1 ms |
1620 KB |
Output is correct |
9 |
Correct |
1 ms |
1620 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
1 ms |
1620 KB |
Output is correct |
12 |
Correct |
1 ms |
1620 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
9 ms |
8788 KB |
Output is correct |
15 |
Correct |
3 ms |
5448 KB |
Output is correct |
16 |
Correct |
4 ms |
5076 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
12 ms |
9584 KB |
Output is correct |
19 |
Correct |
8 ms |
9368 KB |
Output is correct |
20 |
Correct |
7 ms |
9320 KB |
Output is correct |
21 |
Correct |
12 ms |
9504 KB |
Output is correct |
22 |
Correct |
7 ms |
9368 KB |
Output is correct |
23 |
Correct |
7 ms |
9300 KB |
Output is correct |
24 |
Correct |
10 ms |
9556 KB |
Output is correct |
25 |
Correct |
7 ms |
9428 KB |
Output is correct |
26 |
Correct |
7 ms |
9240 KB |
Output is correct |
27 |
Correct |
314 ms |
107460 KB |
Output is correct |
28 |
Correct |
13 ms |
28628 KB |
Output is correct |
29 |
Correct |
10 ms |
10088 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
259 ms |
89780 KB |
Output is correct |
32 |
Correct |
256 ms |
107548 KB |
Output is correct |
33 |
Correct |
231 ms |
107096 KB |
Output is correct |
34 |
Correct |
271 ms |
103884 KB |
Output is correct |
35 |
Correct |
244 ms |
107336 KB |
Output is correct |
36 |
Correct |
230 ms |
106988 KB |
Output is correct |
37 |
Correct |
334 ms |
107456 KB |
Output is correct |
38 |
Correct |
181 ms |
89712 KB |
Output is correct |
39 |
Correct |
173 ms |
89508 KB |
Output is correct |