#include <bits/stdc++.h>
using namespace std;
int main()
{
int H,W; cin >> H >> W;
vector<vector<int>> suforbs(H,vector<int>(W)), sufing(W,vector<int>(H));
vector<string> grid(H);
for(int i = 0;i<H;++i){
cin >> grid[i];
}
for(int i = 0;i<H;++i){
suforbs[i][W-1] = ((grid[i][W-1] == 'O') ? 1 : 0);
for(int j = W-2;j>=0;--j){
if(grid[i][j] == 'O') suforbs[i][j] = suforbs[i][j+1]+1;
else suforbs[i][j] = suforbs[i][j+1];
}
}
for(int i = 0;i<W;++i){
sufing[i][H-1] = ((grid[H-1][i] == 'I') ? 1 : 0);
//cout << "ok";
for(int j = H-2;j>=0;--j){
if(grid[j][i] == 'I') sufing[i][j] = sufing[i][j+1]+1;
else sufing[i][j] = sufing[i][j+1];
}
//cout << "ok";
}
//cout << "ok";
int ans = 0;
for(int i = 0;i<H-1;++i){
for(int j = 0;j<W-1;++j){
if(grid[i][j] == 'J'){
ans += suforbs[i][j+1]*sufing[j][i+1];
}
}
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
304 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 |
340 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 |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
304 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 |
340 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 |
304 KB |
Output is correct |
14 |
Correct |
6 ms |
2260 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
5 ms |
1716 KB |
Output is correct |
17 |
Correct |
1 ms |
296 KB |
Output is correct |
18 |
Correct |
7 ms |
3012 KB |
Output is correct |
19 |
Correct |
6 ms |
2644 KB |
Output is correct |
20 |
Incorrect |
6 ms |
2900 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
304 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 |
340 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 |
304 KB |
Output is correct |
14 |
Correct |
6 ms |
2260 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
5 ms |
1716 KB |
Output is correct |
17 |
Correct |
1 ms |
296 KB |
Output is correct |
18 |
Correct |
7 ms |
3012 KB |
Output is correct |
19 |
Correct |
6 ms |
2644 KB |
Output is correct |
20 |
Incorrect |
6 ms |
2900 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |