#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <stack>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define MAXI (int) 1e6
ll a[MAXI];
ll si[MAXI];
ll r[MAXI];
ll maxi = 0;
ll sum = 0;
void solve(){
int h,w; cin >> h >> w;
char mat[h][w];
vector<int> down(w,0);
vector<int> right(h,0);
for(int i = 0;i<h;i++){
for(int j =0;j<w;j++){
cin >> mat[i][j];
if(mat[i][j] == 'I') down[j]++;
if(mat[i][j] == 'O') right[i]++;
}
}
for(int i = 0;i<h;i++){
for(int j =0;j<w;j++){
if(mat[i][j] == 'I') down[j]--;
if(mat[i][j] == 'O') right[i]--;
if(mat[i][j] == 'J') sum += down[j]*right[i];
}
}
cout << sum;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
cout << fixed << setprecision(8);
int t = 1;
//cin >> t;
while(t){
solve();
t--;
cout << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
6 ms |
596 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
584 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
8 ms |
724 KB |
Output is correct |
19 |
Correct |
5 ms |
724 KB |
Output is correct |
20 |
Correct |
4 ms |
720 KB |
Output is correct |
21 |
Correct |
8 ms |
852 KB |
Output is correct |
22 |
Correct |
6 ms |
724 KB |
Output is correct |
23 |
Correct |
5 ms |
852 KB |
Output is correct |
24 |
Correct |
7 ms |
824 KB |
Output is correct |
25 |
Correct |
5 ms |
724 KB |
Output is correct |
26 |
Correct |
4 ms |
812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
6 ms |
596 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
584 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
8 ms |
724 KB |
Output is correct |
19 |
Correct |
5 ms |
724 KB |
Output is correct |
20 |
Correct |
4 ms |
720 KB |
Output is correct |
21 |
Correct |
8 ms |
852 KB |
Output is correct |
22 |
Correct |
6 ms |
724 KB |
Output is correct |
23 |
Correct |
5 ms |
852 KB |
Output is correct |
24 |
Correct |
7 ms |
824 KB |
Output is correct |
25 |
Correct |
5 ms |
724 KB |
Output is correct |
26 |
Correct |
4 ms |
812 KB |
Output is correct |
27 |
Correct |
244 ms |
16832 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
10 ms |
1492 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
190 ms |
12444 KB |
Output is correct |
32 |
Correct |
174 ms |
17768 KB |
Output is correct |
33 |
Correct |
129 ms |
17816 KB |
Output is correct |
34 |
Correct |
220 ms |
14504 KB |
Output is correct |
35 |
Correct |
181 ms |
17812 KB |
Output is correct |
36 |
Correct |
129 ms |
17868 KB |
Output is correct |
37 |
Correct |
238 ms |
17824 KB |
Output is correct |
38 |
Correct |
113 ms |
12408 KB |
Output is correct |
39 |
Correct |
89 ms |
12416 KB |
Output is correct |