// Problem: B - Bitaro the Brave
// Contest: Virtual Judge - THT - Day 14
// URL: https://vjudge.net/contest/571691#problem/B
// Memory Limit: 268 MB
// Time Limit: 1000 ms
#include <bits/stdc++.h>
#define ll long long
#define sp << " "
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
ll n, m, k, t, s;
char c[3005][3005];
ll a[3005][3005][3], b[3005][3005][3];
int main(){
faster;
cin >> n >> m;
for(ll i = 1; i <= n; i++){
for(ll j = 1; j <= m; j++) cin >> c[i][j];
}
for(ll i = 1; i <= n; i++){
for(ll j = m; j >= 1; j--){
a[i][j][1]=a[i][j+1][1];
if(c[i][j]=='O') a[i][j][1]++;
}
}
for(ll j = 1; j <= m; j++){
for(ll i = n; i >= 1; i--){
b[i][j][2]=b[i+1][j][2];
if(c[i][j]=='I') b[i][j][2]++;
}
}
for(ll i = 1; i <= n; i++){
for(ll j = 1; j <= m; j++){
if(c[i][j]=='J')s+=(a[i][j][1]*b[i][j][2]);
}
}
cout << s;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
392 KB |
Output is correct |
5 |
Correct |
1 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1740 KB |
Output is correct |
8 |
Correct |
1 ms |
1876 KB |
Output is correct |
9 |
Correct |
1 ms |
1740 KB |
Output is correct |
10 |
Correct |
1 ms |
1748 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
12 |
Correct |
1 ms |
1748 KB |
Output is correct |
13 |
Correct |
2 ms |
1748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
392 KB |
Output is correct |
5 |
Correct |
1 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1740 KB |
Output is correct |
8 |
Correct |
1 ms |
1876 KB |
Output is correct |
9 |
Correct |
1 ms |
1740 KB |
Output is correct |
10 |
Correct |
1 ms |
1748 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
12 |
Correct |
1 ms |
1748 KB |
Output is correct |
13 |
Correct |
2 ms |
1748 KB |
Output is correct |
14 |
Correct |
11 ms |
15060 KB |
Output is correct |
15 |
Correct |
2 ms |
5200 KB |
Output is correct |
16 |
Correct |
8 ms |
9328 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
13 ms |
17828 KB |
Output is correct |
19 |
Correct |
12 ms |
17408 KB |
Output is correct |
20 |
Correct |
12 ms |
17456 KB |
Output is correct |
21 |
Correct |
14 ms |
17804 KB |
Output is correct |
22 |
Correct |
12 ms |
17364 KB |
Output is correct |
23 |
Correct |
12 ms |
17464 KB |
Output is correct |
24 |
Correct |
14 ms |
17772 KB |
Output is correct |
25 |
Correct |
12 ms |
17364 KB |
Output is correct |
26 |
Correct |
12 ms |
17540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
392 KB |
Output is correct |
5 |
Correct |
1 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1740 KB |
Output is correct |
8 |
Correct |
1 ms |
1876 KB |
Output is correct |
9 |
Correct |
1 ms |
1740 KB |
Output is correct |
10 |
Correct |
1 ms |
1748 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
12 |
Correct |
1 ms |
1748 KB |
Output is correct |
13 |
Correct |
2 ms |
1748 KB |
Output is correct |
14 |
Correct |
11 ms |
15060 KB |
Output is correct |
15 |
Correct |
2 ms |
5200 KB |
Output is correct |
16 |
Correct |
8 ms |
9328 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
13 ms |
17828 KB |
Output is correct |
19 |
Correct |
12 ms |
17408 KB |
Output is correct |
20 |
Correct |
12 ms |
17456 KB |
Output is correct |
21 |
Correct |
14 ms |
17804 KB |
Output is correct |
22 |
Correct |
12 ms |
17364 KB |
Output is correct |
23 |
Correct |
12 ms |
17464 KB |
Output is correct |
24 |
Correct |
14 ms |
17772 KB |
Output is correct |
25 |
Correct |
12 ms |
17364 KB |
Output is correct |
26 |
Correct |
12 ms |
17540 KB |
Output is correct |
27 |
Runtime error |
238 ms |
274432 KB |
Execution killed with signal 9 |
28 |
Halted |
0 ms |
0 KB |
- |