//khodaya khodet komak kon
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int N = 3000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;
char grid[N][N];
int n, m, R[N][N], C[N][N];
int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++){
cin >> grid[i][j];
if (grid[i][j] == 'I') C[j][i] = 1;
if (grid[i][j] == 'O') R[i][j] = 1;
};
ll ans = 0;
for (int i = 1; i <= n; i++) for (int j = m; j >= 1; j--) R[i][j] += R[i][j + 1];
for (int j = 1; j <= m; j++) for (int i = n; i >= 1; i--) C[j][i] += C[j][i + 1];
for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++){
if (grid[i][j] == 'J'){
ans += R[i][j + 1] * C[j][i + 1];
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1408 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1408 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
14 |
Correct |
13 ms |
7040 KB |
Output is correct |
15 |
Correct |
6 ms |
3328 KB |
Output is correct |
16 |
Correct |
10 ms |
5248 KB |
Output is correct |
17 |
Correct |
5 ms |
1536 KB |
Output is correct |
18 |
Correct |
16 ms |
8064 KB |
Output is correct |
19 |
Correct |
14 ms |
7936 KB |
Output is correct |
20 |
Correct |
12 ms |
7936 KB |
Output is correct |
21 |
Correct |
16 ms |
8064 KB |
Output is correct |
22 |
Correct |
13 ms |
7808 KB |
Output is correct |
23 |
Correct |
12 ms |
7936 KB |
Output is correct |
24 |
Correct |
16 ms |
8064 KB |
Output is correct |
25 |
Correct |
13 ms |
7936 KB |
Output is correct |
26 |
Correct |
13 ms |
7936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1408 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
14 |
Correct |
13 ms |
7040 KB |
Output is correct |
15 |
Correct |
6 ms |
3328 KB |
Output is correct |
16 |
Correct |
10 ms |
5248 KB |
Output is correct |
17 |
Correct |
5 ms |
1536 KB |
Output is correct |
18 |
Correct |
16 ms |
8064 KB |
Output is correct |
19 |
Correct |
14 ms |
7936 KB |
Output is correct |
20 |
Correct |
12 ms |
7936 KB |
Output is correct |
21 |
Correct |
16 ms |
8064 KB |
Output is correct |
22 |
Correct |
13 ms |
7808 KB |
Output is correct |
23 |
Correct |
12 ms |
7936 KB |
Output is correct |
24 |
Correct |
16 ms |
8064 KB |
Output is correct |
25 |
Correct |
13 ms |
7936 KB |
Output is correct |
26 |
Correct |
13 ms |
7936 KB |
Output is correct |
27 |
Correct |
304 ms |
78456 KB |
Output is correct |
28 |
Correct |
13 ms |
16768 KB |
Output is correct |
29 |
Correct |
28 ms |
17228 KB |
Output is correct |
30 |
Correct |
10 ms |
9856 KB |
Output is correct |
31 |
Correct |
244 ms |
67220 KB |
Output is correct |
32 |
Correct |
250 ms |
80120 KB |
Output is correct |
33 |
Correct |
220 ms |
80248 KB |
Output is correct |
34 |
Correct |
262 ms |
73068 KB |
Output is correct |
35 |
Correct |
267 ms |
80152 KB |
Output is correct |
36 |
Correct |
213 ms |
80248 KB |
Output is correct |
37 |
Correct |
316 ms |
80484 KB |
Output is correct |
38 |
Correct |
161 ms |
66940 KB |
Output is correct |
39 |
Correct |
156 ms |
66936 KB |
Output is correct |