#include <bits/stdc++.h>
#define int long long
#define f(i, a, b) for(int i = a; i <= b; i++)
#define fr(i, a, b) for(int i = a; i >= b; i--)
#define pii pair <int, int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define in insert
#define vvec vector<vector<int>>
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
const int N = 3003;
int n, m, cnt[N][N], cnt2[N][N], a[N][N];
signed main()
{
fast;
cin >> n >> m;
f(i, 1, n)
f(j, 1, m)
{
char kt; cin >> kt;
if(kt == 'J') a[i][j] = 1;
else if(kt == 'O') a[i][j] = 2;
else a[i][j] = 3;
}
f(i, 1, n)
fr(j, m, 1) cnt[i][j] = (a[i][j] == 2) + cnt[i][j + 1];
fr(i, n, 1)
f(j, 1, m) cnt2[i][j] = (a[i][j] == 3) + cnt2[i + 1][j];
int res = 0;
f(i, 1, n)
f(j, 1, m)
if(a[i][j] == 1) res += cnt[i][j] * cnt2[i][j];
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Correct |
3 ms |
7348 KB |
Output is correct |
6 |
Correct |
2 ms |
7260 KB |
Output is correct |
7 |
Correct |
1 ms |
4964 KB |
Output is correct |
8 |
Correct |
3 ms |
7120 KB |
Output is correct |
9 |
Correct |
1 ms |
7260 KB |
Output is correct |
10 |
Correct |
1 ms |
4952 KB |
Output is correct |
11 |
Correct |
2 ms |
7256 KB |
Output is correct |
12 |
Correct |
2 ms |
7260 KB |
Output is correct |
13 |
Correct |
2 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Correct |
3 ms |
7348 KB |
Output is correct |
6 |
Correct |
2 ms |
7260 KB |
Output is correct |
7 |
Correct |
1 ms |
4964 KB |
Output is correct |
8 |
Correct |
3 ms |
7120 KB |
Output is correct |
9 |
Correct |
1 ms |
7260 KB |
Output is correct |
10 |
Correct |
1 ms |
4952 KB |
Output is correct |
11 |
Correct |
2 ms |
7256 KB |
Output is correct |
12 |
Correct |
2 ms |
7260 KB |
Output is correct |
13 |
Correct |
2 ms |
4956 KB |
Output is correct |
14 |
Correct |
12 ms |
28760 KB |
Output is correct |
15 |
Correct |
4 ms |
22620 KB |
Output is correct |
16 |
Correct |
5 ms |
15196 KB |
Output is correct |
17 |
Correct |
1 ms |
2904 KB |
Output is correct |
18 |
Correct |
13 ms |
29188 KB |
Output is correct |
19 |
Correct |
8 ms |
29276 KB |
Output is correct |
20 |
Correct |
9 ms |
27740 KB |
Output is correct |
21 |
Correct |
14 ms |
29156 KB |
Output is correct |
22 |
Correct |
9 ms |
29280 KB |
Output is correct |
23 |
Correct |
8 ms |
27744 KB |
Output is correct |
24 |
Correct |
12 ms |
29224 KB |
Output is correct |
25 |
Correct |
8 ms |
29280 KB |
Output is correct |
26 |
Correct |
8 ms |
27740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Correct |
3 ms |
7348 KB |
Output is correct |
6 |
Correct |
2 ms |
7260 KB |
Output is correct |
7 |
Correct |
1 ms |
4964 KB |
Output is correct |
8 |
Correct |
3 ms |
7120 KB |
Output is correct |
9 |
Correct |
1 ms |
7260 KB |
Output is correct |
10 |
Correct |
1 ms |
4952 KB |
Output is correct |
11 |
Correct |
2 ms |
7256 KB |
Output is correct |
12 |
Correct |
2 ms |
7260 KB |
Output is correct |
13 |
Correct |
2 ms |
4956 KB |
Output is correct |
14 |
Correct |
12 ms |
28760 KB |
Output is correct |
15 |
Correct |
4 ms |
22620 KB |
Output is correct |
16 |
Correct |
5 ms |
15196 KB |
Output is correct |
17 |
Correct |
1 ms |
2904 KB |
Output is correct |
18 |
Correct |
13 ms |
29188 KB |
Output is correct |
19 |
Correct |
8 ms |
29276 KB |
Output is correct |
20 |
Correct |
9 ms |
27740 KB |
Output is correct |
21 |
Correct |
14 ms |
29156 KB |
Output is correct |
22 |
Correct |
9 ms |
29280 KB |
Output is correct |
23 |
Correct |
8 ms |
27744 KB |
Output is correct |
24 |
Correct |
12 ms |
29224 KB |
Output is correct |
25 |
Correct |
8 ms |
29280 KB |
Output is correct |
26 |
Correct |
8 ms |
27740 KB |
Output is correct |
27 |
Correct |
305 ms |
220164 KB |
Output is correct |
28 |
Correct |
17 ms |
119056 KB |
Output is correct |
29 |
Correct |
13 ms |
20072 KB |
Output is correct |
30 |
Correct |
1 ms |
2920 KB |
Output is correct |
31 |
Correct |
203 ms |
184328 KB |
Output is correct |
32 |
Correct |
197 ms |
220756 KB |
Output is correct |
33 |
Correct |
182 ms |
220400 KB |
Output is correct |
34 |
Correct |
249 ms |
213756 KB |
Output is correct |
35 |
Correct |
199 ms |
220752 KB |
Output is correct |
36 |
Correct |
165 ms |
220240 KB |
Output is correct |
37 |
Correct |
290 ms |
220824 KB |
Output is correct |
38 |
Correct |
135 ms |
184288 KB |
Output is correct |
39 |
Correct |
118 ms |
183760 KB |
Output is correct |