/*
░██████╗░█████╗░░██████╗██╗░░░██╗ ░██████╗░░█████╗░████████╗░█████╗░
██╔════╝██╔══██╗██╔════╝██║░░░██║ ██╔════╝░██╔══██╗╚══██╔══╝██╔══██╗
╚█████╗░██║░░██║╚█████╗░██║░░░██║ ██║░░██╗░███████║░░░██║░░░███████║
░╚═══██╗██║░░██║░╚═══██╗██║░░░██║ ██║░░╚██╗██╔══██║░░░██║░░░██╔══██║
██████╔╝╚█████╔╝██████╔╝╚██████╔╝ ╚██████╔╝██║░░██║░░░██║░░░██║░░██║
╚═════╝░░╚════╝░╚═════╝░░╚═════╝░ ░╚═════╝░╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═╝
*/
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std;
const int INF = 1000000007;
const int N = 3005;
char a[N][N];
int po[N][N], pi[N][N];
int main() {
ios_base :: sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
po[i][j] = po[i][j - 1] + (a[i][j] == 'O');
}
}
for (int j = 0; j < m; j++) {
for (int i = 0; i < n; i++) {
pi[i][j] = pi[i - 1][j] + (a[i][j] == 'I');
}
}
int co, ci;
long long res = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (a[i][j] == 'J') {
co = po[i][m - 1] - po[i][j - 1];
ci = pi[n - 1][j] - pi[i - 1][j];
res += 1LL * co * ci;
}
}
}
cout << res << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
1516 KB |
Output is correct |
6 |
Correct |
1 ms |
1516 KB |
Output is correct |
7 |
Correct |
1 ms |
1388 KB |
Output is correct |
8 |
Correct |
1 ms |
1516 KB |
Output is correct |
9 |
Correct |
1 ms |
1536 KB |
Output is correct |
10 |
Correct |
1 ms |
1388 KB |
Output is correct |
11 |
Correct |
1 ms |
1528 KB |
Output is correct |
12 |
Correct |
1 ms |
1516 KB |
Output is correct |
13 |
Correct |
1 ms |
1388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
1516 KB |
Output is correct |
6 |
Correct |
1 ms |
1516 KB |
Output is correct |
7 |
Correct |
1 ms |
1388 KB |
Output is correct |
8 |
Correct |
1 ms |
1516 KB |
Output is correct |
9 |
Correct |
1 ms |
1536 KB |
Output is correct |
10 |
Correct |
1 ms |
1388 KB |
Output is correct |
11 |
Correct |
1 ms |
1528 KB |
Output is correct |
12 |
Correct |
1 ms |
1516 KB |
Output is correct |
13 |
Correct |
1 ms |
1388 KB |
Output is correct |
14 |
Correct |
10 ms |
7532 KB |
Output is correct |
15 |
Correct |
3 ms |
4972 KB |
Output is correct |
16 |
Correct |
5 ms |
4332 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
11 ms |
8044 KB |
Output is correct |
19 |
Correct |
10 ms |
7916 KB |
Output is correct |
20 |
Correct |
10 ms |
7912 KB |
Output is correct |
21 |
Correct |
12 ms |
8044 KB |
Output is correct |
22 |
Correct |
10 ms |
7916 KB |
Output is correct |
23 |
Correct |
10 ms |
7916 KB |
Output is correct |
24 |
Correct |
11 ms |
8044 KB |
Output is correct |
25 |
Correct |
10 ms |
7916 KB |
Output is correct |
26 |
Correct |
10 ms |
7916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
1516 KB |
Output is correct |
6 |
Correct |
1 ms |
1516 KB |
Output is correct |
7 |
Correct |
1 ms |
1388 KB |
Output is correct |
8 |
Correct |
1 ms |
1516 KB |
Output is correct |
9 |
Correct |
1 ms |
1536 KB |
Output is correct |
10 |
Correct |
1 ms |
1388 KB |
Output is correct |
11 |
Correct |
1 ms |
1528 KB |
Output is correct |
12 |
Correct |
1 ms |
1516 KB |
Output is correct |
13 |
Correct |
1 ms |
1388 KB |
Output is correct |
14 |
Correct |
10 ms |
7532 KB |
Output is correct |
15 |
Correct |
3 ms |
4972 KB |
Output is correct |
16 |
Correct |
5 ms |
4332 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
11 ms |
8044 KB |
Output is correct |
19 |
Correct |
10 ms |
7916 KB |
Output is correct |
20 |
Correct |
10 ms |
7912 KB |
Output is correct |
21 |
Correct |
12 ms |
8044 KB |
Output is correct |
22 |
Correct |
10 ms |
7916 KB |
Output is correct |
23 |
Correct |
10 ms |
7916 KB |
Output is correct |
24 |
Correct |
11 ms |
8044 KB |
Output is correct |
25 |
Correct |
10 ms |
7916 KB |
Output is correct |
26 |
Correct |
10 ms |
7916 KB |
Output is correct |
27 |
Correct |
399 ms |
88028 KB |
Output is correct |
28 |
Correct |
17 ms |
26092 KB |
Output is correct |
29 |
Correct |
18 ms |
7916 KB |
Output is correct |
30 |
Correct |
1 ms |
620 KB |
Output is correct |
31 |
Correct |
296 ms |
72676 KB |
Output is correct |
32 |
Correct |
384 ms |
88548 KB |
Output is correct |
33 |
Correct |
375 ms |
88420 KB |
Output is correct |
34 |
Correct |
340 ms |
84324 KB |
Output is correct |
35 |
Correct |
374 ms |
88548 KB |
Output is correct |
36 |
Correct |
364 ms |
88292 KB |
Output is correct |
37 |
Correct |
396 ms |
88548 KB |
Output is correct |
38 |
Correct |
261 ms |
72548 KB |
Output is correct |
39 |
Correct |
264 ms |
72292 KB |
Output is correct |