#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define pi pair<int,int>
#define vi vector<int>
#define int ll
const int NMAX = 600;
int N,M;
vector<string>A;
int O[NMAX][NMAX],I[NMAX][NMAX];
void solve() {
cin >> N >> M;
A = vector<string>(N);
for (int i = 0; i < N;++i)
cin >> A[i];
for (int i = 0; i < N;++i)
for (int j = 0; j < M;++j) {
if (j)
O[i][j] += O[i][j - 1];
if(i)
I[i][j] += I[i - 1][j];
if(A[i][j] == 'O') O[i][j]++;
if(A[i][j] == 'I') I[i][j]++;
}
int cnt = 0;
for (int i = 0; i < N;++i)
for (int j = 0; j < M;++j) {
if(A[i][j] == 'J')
cnt += (O[i][M - 1] - O[i][j]) * (I[N - 1][j] - I[i][j]);
}
cout << cnt;
}
main(){
solve();
}
Compilation message
joi2019_ho_t1.cpp:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
39 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1220 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1376 KB |
Output is correct |
12 |
Correct |
1 ms |
1376 KB |
Output is correct |
13 |
Correct |
1 ms |
1120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1220 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1376 KB |
Output is correct |
12 |
Correct |
1 ms |
1376 KB |
Output is correct |
13 |
Correct |
1 ms |
1120 KB |
Output is correct |
14 |
Correct |
7 ms |
5476 KB |
Output is correct |
15 |
Correct |
2 ms |
3780 KB |
Output is correct |
16 |
Correct |
3 ms |
3272 KB |
Output is correct |
17 |
Correct |
1 ms |
356 KB |
Output is correct |
18 |
Correct |
7 ms |
5732 KB |
Output is correct |
19 |
Correct |
6 ms |
5464 KB |
Output is correct |
20 |
Correct |
7 ms |
5732 KB |
Output is correct |
21 |
Correct |
10 ms |
5884 KB |
Output is correct |
22 |
Correct |
6 ms |
5640 KB |
Output is correct |
23 |
Correct |
6 ms |
5728 KB |
Output is correct |
24 |
Correct |
7 ms |
5728 KB |
Output is correct |
25 |
Correct |
7 ms |
5472 KB |
Output is correct |
26 |
Correct |
6 ms |
5732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1220 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1376 KB |
Output is correct |
12 |
Correct |
1 ms |
1376 KB |
Output is correct |
13 |
Correct |
1 ms |
1120 KB |
Output is correct |
14 |
Correct |
7 ms |
5476 KB |
Output is correct |
15 |
Correct |
2 ms |
3780 KB |
Output is correct |
16 |
Correct |
3 ms |
3272 KB |
Output is correct |
17 |
Correct |
1 ms |
356 KB |
Output is correct |
18 |
Correct |
7 ms |
5732 KB |
Output is correct |
19 |
Correct |
6 ms |
5464 KB |
Output is correct |
20 |
Correct |
7 ms |
5732 KB |
Output is correct |
21 |
Correct |
10 ms |
5884 KB |
Output is correct |
22 |
Correct |
6 ms |
5640 KB |
Output is correct |
23 |
Correct |
6 ms |
5728 KB |
Output is correct |
24 |
Correct |
7 ms |
5728 KB |
Output is correct |
25 |
Correct |
7 ms |
5472 KB |
Output is correct |
26 |
Correct |
6 ms |
5732 KB |
Output is correct |
27 |
Runtime error |
134 ms |
43180 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |