#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3003;
long long orb[MAXN], ingot[MAXN];
string grid[MAXN];
int main() {
cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("input.txt", "r", stdin);
int n, m; cin >> n >> m;
for(int i = 0; i < n; ++i){
cin >> grid[i];
for(int j = 0; j < m; ++j){
if(grid[i][j] == 'I') ++ingot[j];
else if(grid[i][j] == 'O') ++orb[i];
}
}
long long tot = 0;
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j){
if(grid[i][j] == 'J')
tot += orb[i] * ingot[j];
else if(grid[i][j] == 'O')
--orb[i];
else if(grid[i][j] == 'I')
--ingot[j];
}
}
cout << tot << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
896 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
640 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
896 KB |
Output is correct |
19 |
Correct |
3 ms |
896 KB |
Output is correct |
20 |
Correct |
2 ms |
896 KB |
Output is correct |
21 |
Correct |
5 ms |
1024 KB |
Output is correct |
22 |
Correct |
2 ms |
896 KB |
Output is correct |
23 |
Correct |
2 ms |
896 KB |
Output is correct |
24 |
Correct |
5 ms |
896 KB |
Output is correct |
25 |
Correct |
2 ms |
896 KB |
Output is correct |
26 |
Correct |
2 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
896 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
640 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
896 KB |
Output is correct |
19 |
Correct |
3 ms |
896 KB |
Output is correct |
20 |
Correct |
2 ms |
896 KB |
Output is correct |
21 |
Correct |
5 ms |
1024 KB |
Output is correct |
22 |
Correct |
2 ms |
896 KB |
Output is correct |
23 |
Correct |
2 ms |
896 KB |
Output is correct |
24 |
Correct |
5 ms |
896 KB |
Output is correct |
25 |
Correct |
2 ms |
896 KB |
Output is correct |
26 |
Correct |
2 ms |
896 KB |
Output is correct |
27 |
Correct |
151 ms |
17972 KB |
Output is correct |
28 |
Correct |
1 ms |
512 KB |
Output is correct |
29 |
Correct |
4 ms |
1792 KB |
Output is correct |
30 |
Correct |
1 ms |
512 KB |
Output is correct |
31 |
Correct |
109 ms |
13296 KB |
Output is correct |
32 |
Correct |
60 ms |
18808 KB |
Output is correct |
33 |
Correct |
48 ms |
19000 KB |
Output is correct |
34 |
Correct |
127 ms |
15224 KB |
Output is correct |
35 |
Correct |
59 ms |
18808 KB |
Output is correct |
36 |
Correct |
47 ms |
18936 KB |
Output is correct |
37 |
Correct |
143 ms |
19064 KB |
Output is correct |
38 |
Correct |
44 ms |
13056 KB |
Output is correct |
39 |
Correct |
33 ms |
13184 KB |
Output is correct |