#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
#define MAXN 3010
lld rez, O[MAXN][MAXN], I[MAXN][MAXN];
string s[MAXN];
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
int H, W; cin >> H >> W;
for(int i = 1; i <= H; i++) {
cin >> s[i];
s[i] = '#' + s[i] + '#';
}
for(int i = 1; i <= H; i++) {
for(int j = W; j >= 1; j--) {
O[i][j] = O[i][j+1] + (s[i][j] == 'O');
}
}
for(int j = 1; j <= W; j++) {
for(int i = H; i >= 1; i--) {
I[i][j] = I[i+1][j] + (s[i][j] == 'I');
}
}
for(int i = 1; i <= H; i++) {
for(int j = 1; j <= W; j++) {
if(s[i][j] == 'J') {
rez += O[i][j]*I[i][j];
}
}
}
cout << rez;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1372 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
10 |
Correct |
4 ms |
1272 KB |
Output is correct |
11 |
Correct |
3 ms |
1400 KB |
Output is correct |
12 |
Correct |
4 ms |
1400 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1372 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
10 |
Correct |
4 ms |
1272 KB |
Output is correct |
11 |
Correct |
3 ms |
1400 KB |
Output is correct |
12 |
Correct |
4 ms |
1400 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
11 ms |
8056 KB |
Output is correct |
15 |
Correct |
5 ms |
3960 KB |
Output is correct |
16 |
Correct |
7 ms |
4984 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
14 ms |
9208 KB |
Output is correct |
19 |
Correct |
12 ms |
8952 KB |
Output is correct |
20 |
Correct |
12 ms |
8952 KB |
Output is correct |
21 |
Correct |
13 ms |
9080 KB |
Output is correct |
22 |
Correct |
12 ms |
8952 KB |
Output is correct |
23 |
Correct |
12 ms |
8952 KB |
Output is correct |
24 |
Correct |
13 ms |
9208 KB |
Output is correct |
25 |
Correct |
12 ms |
8952 KB |
Output is correct |
26 |
Correct |
12 ms |
8952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
3 ms |
1400 KB |
Output is correct |
7 |
Correct |
3 ms |
1372 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
3 ms |
1400 KB |
Output is correct |
10 |
Correct |
4 ms |
1272 KB |
Output is correct |
11 |
Correct |
3 ms |
1400 KB |
Output is correct |
12 |
Correct |
4 ms |
1400 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
11 ms |
8056 KB |
Output is correct |
15 |
Correct |
5 ms |
3960 KB |
Output is correct |
16 |
Correct |
7 ms |
4984 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
14 ms |
9208 KB |
Output is correct |
19 |
Correct |
12 ms |
8952 KB |
Output is correct |
20 |
Correct |
12 ms |
8952 KB |
Output is correct |
21 |
Correct |
13 ms |
9080 KB |
Output is correct |
22 |
Correct |
12 ms |
8952 KB |
Output is correct |
23 |
Correct |
12 ms |
8952 KB |
Output is correct |
24 |
Correct |
13 ms |
9208 KB |
Output is correct |
25 |
Correct |
12 ms |
8952 KB |
Output is correct |
26 |
Correct |
12 ms |
8952 KB |
Output is correct |
27 |
Correct |
476 ms |
166748 KB |
Output is correct |
28 |
Correct |
21 ms |
19704 KB |
Output is correct |
29 |
Correct |
20 ms |
14584 KB |
Output is correct |
30 |
Correct |
3 ms |
1016 KB |
Output is correct |
31 |
Correct |
358 ms |
136696 KB |
Output is correct |
32 |
Correct |
474 ms |
168200 KB |
Output is correct |
33 |
Correct |
482 ms |
167928 KB |
Output is correct |
34 |
Correct |
422 ms |
158488 KB |
Output is correct |
35 |
Correct |
457 ms |
168312 KB |
Output is correct |
36 |
Correct |
450 ms |
167672 KB |
Output is correct |
37 |
Correct |
490 ms |
168312 KB |
Output is correct |
38 |
Correct |
357 ms |
135800 KB |
Output is correct |
39 |
Correct |
322 ms |
136092 KB |
Output is correct |