#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d))
#define szof(x) ((int)(x).size())
#define vi vector<int>
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
const int INF = INT_MAX;
const int LNF = INF*INF;
const int MOD = 1000000007;
const int mod = 998244353;
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
const int MAX = 3010;
int H, W;
char arr[MAX][MAX];
int so[MAX][MAX], si[MAX][MAX];
int res;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>H>>W;
FOR(i, 1, H, 1){
FOR(j, 1, W, 1){
cin>>arr[i][j];
}
}
FOR(i, 1, H, 1){
for(int j=W; j>=1; j--){
so[i][j] = so[i][j+1] + (arr[i][j] == 'O');
}
}
FOR(j, 1, W, 1){
for(int i=H; i>=1; i--){
si[i][j] = si[i+1][j] + (arr[i][j] == 'I');
}
}
FOR(i, 1, H, 1){
FOR(j, 1, W, 1){
if(arr[i][j] == 'J') res += so[i][j] * si[i][j];
}
}
cout<<res<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
452 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1488 KB |
Output is correct |
6 |
Correct |
2 ms |
1488 KB |
Output is correct |
7 |
Correct |
2 ms |
1360 KB |
Output is correct |
8 |
Correct |
2 ms |
1488 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1356 KB |
Output is correct |
11 |
Correct |
2 ms |
1480 KB |
Output is correct |
12 |
Correct |
1 ms |
1488 KB |
Output is correct |
13 |
Correct |
2 ms |
1360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
452 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1488 KB |
Output is correct |
6 |
Correct |
2 ms |
1488 KB |
Output is correct |
7 |
Correct |
2 ms |
1360 KB |
Output is correct |
8 |
Correct |
2 ms |
1488 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1356 KB |
Output is correct |
11 |
Correct |
2 ms |
1480 KB |
Output is correct |
12 |
Correct |
1 ms |
1488 KB |
Output is correct |
13 |
Correct |
2 ms |
1360 KB |
Output is correct |
14 |
Correct |
12 ms |
9040 KB |
Output is correct |
15 |
Correct |
3 ms |
5072 KB |
Output is correct |
16 |
Correct |
8 ms |
5336 KB |
Output is correct |
17 |
Correct |
1 ms |
464 KB |
Output is correct |
18 |
Correct |
13 ms |
9900 KB |
Output is correct |
19 |
Correct |
11 ms |
9680 KB |
Output is correct |
20 |
Correct |
11 ms |
9756 KB |
Output is correct |
21 |
Correct |
14 ms |
9976 KB |
Output is correct |
22 |
Correct |
12 ms |
9740 KB |
Output is correct |
23 |
Correct |
14 ms |
9820 KB |
Output is correct |
24 |
Correct |
13 ms |
9960 KB |
Output is correct |
25 |
Correct |
11 ms |
9804 KB |
Output is correct |
26 |
Correct |
13 ms |
9680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
452 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1488 KB |
Output is correct |
6 |
Correct |
2 ms |
1488 KB |
Output is correct |
7 |
Correct |
2 ms |
1360 KB |
Output is correct |
8 |
Correct |
2 ms |
1488 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1356 KB |
Output is correct |
11 |
Correct |
2 ms |
1480 KB |
Output is correct |
12 |
Correct |
1 ms |
1488 KB |
Output is correct |
13 |
Correct |
2 ms |
1360 KB |
Output is correct |
14 |
Correct |
12 ms |
9040 KB |
Output is correct |
15 |
Correct |
3 ms |
5072 KB |
Output is correct |
16 |
Correct |
8 ms |
5336 KB |
Output is correct |
17 |
Correct |
1 ms |
464 KB |
Output is correct |
18 |
Correct |
13 ms |
9900 KB |
Output is correct |
19 |
Correct |
11 ms |
9680 KB |
Output is correct |
20 |
Correct |
11 ms |
9756 KB |
Output is correct |
21 |
Correct |
14 ms |
9976 KB |
Output is correct |
22 |
Correct |
12 ms |
9740 KB |
Output is correct |
23 |
Correct |
14 ms |
9820 KB |
Output is correct |
24 |
Correct |
13 ms |
9960 KB |
Output is correct |
25 |
Correct |
11 ms |
9804 KB |
Output is correct |
26 |
Correct |
13 ms |
9680 KB |
Output is correct |
27 |
Correct |
473 ms |
158500 KB |
Output is correct |
28 |
Correct |
19 ms |
26368 KB |
Output is correct |
29 |
Correct |
24 ms |
13844 KB |
Output is correct |
30 |
Correct |
2 ms |
848 KB |
Output is correct |
31 |
Correct |
347 ms |
131536 KB |
Output is correct |
32 |
Correct |
437 ms |
159224 KB |
Output is correct |
33 |
Correct |
445 ms |
158620 KB |
Output is correct |
34 |
Correct |
390 ms |
152544 KB |
Output is correct |
35 |
Correct |
450 ms |
159044 KB |
Output is correct |
36 |
Correct |
425 ms |
158676 KB |
Output is correct |
37 |
Correct |
478 ms |
159268 KB |
Output is correct |
38 |
Correct |
304 ms |
130772 KB |
Output is correct |
39 |
Correct |
307 ms |
131044 KB |
Output is correct |