#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
// #pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
const int maxn = 500 + 5;
const int INF = 1e9;
const double eps = 1e-7;
string s[maxn];
int r[maxn][maxn], d[maxn][maxn];
int main(void){
fastio;
int h, w;
cin>>h>>w;
for(int i = 0; i < h; i++) cin>>s[i];
for(int i = 0; i < h; i++){
int cnt = 0;
for(int j = w - 1; j >= 0; j--){
if(s[i][j] == 'O') cnt++;
if(s[i][j] == 'J') r[i][j] = cnt;
}
}
for(int j = 0; j < w; j++){
int cnt = 0;
for(int i = h - 1; i >= 0; i--){
if(s[i][j] == 'I') cnt++;
if(s[i][j] == 'J') d[i][j] = cnt;
}
}
ll ans = 0;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
if(s[i][j] == 'J') ans += r[i][j] * d[i][j];
}
}
cout<<ans<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
480 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
0 ms |
860 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
0 ms |
860 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
860 KB |
Output is correct |
12 |
Correct |
0 ms |
860 KB |
Output is correct |
13 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
480 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
0 ms |
860 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
0 ms |
860 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
860 KB |
Output is correct |
12 |
Correct |
0 ms |
860 KB |
Output is correct |
13 |
Correct |
0 ms |
604 KB |
Output is correct |
14 |
Correct |
6 ms |
2908 KB |
Output is correct |
15 |
Correct |
1 ms |
1884 KB |
Output is correct |
16 |
Correct |
1 ms |
1628 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
2960 KB |
Output is correct |
19 |
Correct |
2 ms |
2904 KB |
Output is correct |
20 |
Correct |
2 ms |
2904 KB |
Output is correct |
21 |
Correct |
5 ms |
2720 KB |
Output is correct |
22 |
Correct |
2 ms |
2904 KB |
Output is correct |
23 |
Correct |
2 ms |
2908 KB |
Output is correct |
24 |
Correct |
5 ms |
2908 KB |
Output is correct |
25 |
Correct |
2 ms |
2912 KB |
Output is correct |
26 |
Correct |
2 ms |
2924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
480 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
0 ms |
860 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
0 ms |
860 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
860 KB |
Output is correct |
12 |
Correct |
0 ms |
860 KB |
Output is correct |
13 |
Correct |
0 ms |
604 KB |
Output is correct |
14 |
Correct |
6 ms |
2908 KB |
Output is correct |
15 |
Correct |
1 ms |
1884 KB |
Output is correct |
16 |
Correct |
1 ms |
1628 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
2960 KB |
Output is correct |
19 |
Correct |
2 ms |
2904 KB |
Output is correct |
20 |
Correct |
2 ms |
2904 KB |
Output is correct |
21 |
Correct |
5 ms |
2720 KB |
Output is correct |
22 |
Correct |
2 ms |
2904 KB |
Output is correct |
23 |
Correct |
2 ms |
2908 KB |
Output is correct |
24 |
Correct |
5 ms |
2908 KB |
Output is correct |
25 |
Correct |
2 ms |
2912 KB |
Output is correct |
26 |
Correct |
2 ms |
2924 KB |
Output is correct |
27 |
Runtime error |
4 ms |
5412 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |