#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ifstream in("input.txt");
ofstream out("output.txt");
typedef long long ll;
int h,w;
char tab[5000][5000];
int pref[5000][5000];
int prefb[5000][5000];
int sump[5000];
int main(){
cin>>h>>w;
for(int i=0;i<h;i++){
int sum=0;
for(int y=0;y<w;y++){
cin>>tab[i][y];
if(tab[i][y]=='O')sum++;
else if(tab[i][y]=='I')sump[y]++;
prefb[i][y]=sum;
pref[i][y]=sump[y];
}
}
/*for(int i=0;i<w;i++){
int sum=0;
for(int y=0;y<h;y++){
if(tab[y][i]=='I')sum++;
pref[y][i]=sum;
}
}*/
ll tot=0;
for(int i=0;i<h;i++){
for(int y=0;y<w;y++){
if(tab[i][y]=='J'){
tot+=(prefb[i][w-1]-prefb[i][y])*(pref[h-1][y]-pref[i][y]);
}
}
}
cout<<tot;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
4 ms |
1656 KB |
Output is correct |
6 |
Correct |
4 ms |
1528 KB |
Output is correct |
7 |
Correct |
4 ms |
1528 KB |
Output is correct |
8 |
Correct |
4 ms |
1548 KB |
Output is correct |
9 |
Correct |
4 ms |
1528 KB |
Output is correct |
10 |
Correct |
4 ms |
1528 KB |
Output is correct |
11 |
Correct |
4 ms |
1728 KB |
Output is correct |
12 |
Correct |
4 ms |
1528 KB |
Output is correct |
13 |
Correct |
4 ms |
1612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
4 ms |
1656 KB |
Output is correct |
6 |
Correct |
4 ms |
1528 KB |
Output is correct |
7 |
Correct |
4 ms |
1528 KB |
Output is correct |
8 |
Correct |
4 ms |
1548 KB |
Output is correct |
9 |
Correct |
4 ms |
1528 KB |
Output is correct |
10 |
Correct |
4 ms |
1528 KB |
Output is correct |
11 |
Correct |
4 ms |
1728 KB |
Output is correct |
12 |
Correct |
4 ms |
1528 KB |
Output is correct |
13 |
Correct |
4 ms |
1612 KB |
Output is correct |
14 |
Correct |
31 ms |
8184 KB |
Output is correct |
15 |
Correct |
6 ms |
5496 KB |
Output is correct |
16 |
Correct |
19 ms |
4728 KB |
Output is correct |
17 |
Correct |
3 ms |
508 KB |
Output is correct |
18 |
Correct |
38 ms |
8924 KB |
Output is correct |
19 |
Correct |
34 ms |
8752 KB |
Output is correct |
20 |
Correct |
34 ms |
8672 KB |
Output is correct |
21 |
Correct |
38 ms |
8864 KB |
Output is correct |
22 |
Correct |
34 ms |
8696 KB |
Output is correct |
23 |
Correct |
34 ms |
8568 KB |
Output is correct |
24 |
Correct |
38 ms |
8828 KB |
Output is correct |
25 |
Correct |
33 ms |
8672 KB |
Output is correct |
26 |
Correct |
33 ms |
8660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
4 ms |
1656 KB |
Output is correct |
6 |
Correct |
4 ms |
1528 KB |
Output is correct |
7 |
Correct |
4 ms |
1528 KB |
Output is correct |
8 |
Correct |
4 ms |
1548 KB |
Output is correct |
9 |
Correct |
4 ms |
1528 KB |
Output is correct |
10 |
Correct |
4 ms |
1528 KB |
Output is correct |
11 |
Correct |
4 ms |
1728 KB |
Output is correct |
12 |
Correct |
4 ms |
1528 KB |
Output is correct |
13 |
Correct |
4 ms |
1612 KB |
Output is correct |
14 |
Correct |
31 ms |
8184 KB |
Output is correct |
15 |
Correct |
6 ms |
5496 KB |
Output is correct |
16 |
Correct |
19 ms |
4728 KB |
Output is correct |
17 |
Correct |
3 ms |
508 KB |
Output is correct |
18 |
Correct |
38 ms |
8924 KB |
Output is correct |
19 |
Correct |
34 ms |
8752 KB |
Output is correct |
20 |
Correct |
34 ms |
8672 KB |
Output is correct |
21 |
Correct |
38 ms |
8864 KB |
Output is correct |
22 |
Correct |
34 ms |
8696 KB |
Output is correct |
23 |
Correct |
34 ms |
8568 KB |
Output is correct |
24 |
Correct |
38 ms |
8828 KB |
Output is correct |
25 |
Correct |
33 ms |
8672 KB |
Output is correct |
26 |
Correct |
33 ms |
8660 KB |
Output is correct |
27 |
Execution timed out |
1040 ms |
106764 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |