#include <bits/stdc++.h>
#define endl '\n'
#define fr first
#define sc second
#define all(v) v.begin(),v.end()
#define unq(v) sort( all(v) ); v.erase( unique( all(v) ), v.end() )
#define bout(x) cout << bitset<sizeof(x)*8>(x) << endl
#define mkp(a,b) make_pair(a,b)
#define gcd(a,b) __gcd(a,b)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pi2 = pair<int, int>;
using pl2 = pair<ll, ll>;
using cpl = complex<ld>;
const ld pi = 3.14159265358979323846264338327950288;
const ld tau = 2 * pi;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, ddy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int nx[8] = {1, 2, 2, 1, -1, -2, -2, -1}, ny[8] = {-2, -1, 1, 2, 2, 1, -1, -2};
// #define DEBUG
string mp[3020];
int co[3020][3020], ci[3020][3020];
void Main(){
int h, w; cin >> h >> w;
for (int i = 0; i < h; i++){ cin >> mp[i]; }
for (int i = 0; i < h; i++){
for (int j = w-1; j >= 0; j--){
co[i][j] = co[i][j+1];
if (mp[i][j] == 'O'){ co[i][j] += 1; }
}
}
for (int j = 0; j < w; j++){
for (int i = h-1; i >= 0; i--){
ci[i][j] = ci[i+1][j];
if (mp[i][j] == 'I'){ ci[i][j] += 1; }
}
}
ll ans = 0;
for (int i = 0; i < h; i++){
for (int j = 0; j < w; j++){
if (mp[i][j] == 'J'){ ans += co[i][j] * ci[i][j]; }
}
}
cout << ans;
}
int main(){
#ifndef DEBUG
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#endif
cout.setf(ios::fixed);
cout.precision(0);
Main();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
1228 KB |
Output is correct |
6 |
Correct |
1 ms |
1228 KB |
Output is correct |
7 |
Correct |
2 ms |
1228 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
2 ms |
1228 KB |
Output is correct |
10 |
Correct |
1 ms |
1228 KB |
Output is correct |
11 |
Correct |
1 ms |
1228 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
1100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
1228 KB |
Output is correct |
6 |
Correct |
1 ms |
1228 KB |
Output is correct |
7 |
Correct |
2 ms |
1228 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
2 ms |
1228 KB |
Output is correct |
10 |
Correct |
1 ms |
1228 KB |
Output is correct |
11 |
Correct |
1 ms |
1228 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
1100 KB |
Output is correct |
14 |
Correct |
8 ms |
6312 KB |
Output is correct |
15 |
Correct |
3 ms |
3788 KB |
Output is correct |
16 |
Correct |
4 ms |
3660 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
9 ms |
6860 KB |
Output is correct |
19 |
Correct |
8 ms |
6732 KB |
Output is correct |
20 |
Correct |
7 ms |
6732 KB |
Output is correct |
21 |
Correct |
9 ms |
6840 KB |
Output is correct |
22 |
Correct |
8 ms |
6708 KB |
Output is correct |
23 |
Correct |
7 ms |
6732 KB |
Output is correct |
24 |
Correct |
9 ms |
6860 KB |
Output is correct |
25 |
Correct |
7 ms |
6732 KB |
Output is correct |
26 |
Correct |
7 ms |
6732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
1228 KB |
Output is correct |
6 |
Correct |
1 ms |
1228 KB |
Output is correct |
7 |
Correct |
2 ms |
1228 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
2 ms |
1228 KB |
Output is correct |
10 |
Correct |
1 ms |
1228 KB |
Output is correct |
11 |
Correct |
1 ms |
1228 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
1100 KB |
Output is correct |
14 |
Correct |
8 ms |
6312 KB |
Output is correct |
15 |
Correct |
3 ms |
3788 KB |
Output is correct |
16 |
Correct |
4 ms |
3660 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
9 ms |
6860 KB |
Output is correct |
19 |
Correct |
8 ms |
6732 KB |
Output is correct |
20 |
Correct |
7 ms |
6732 KB |
Output is correct |
21 |
Correct |
9 ms |
6840 KB |
Output is correct |
22 |
Correct |
8 ms |
6708 KB |
Output is correct |
23 |
Correct |
7 ms |
6732 KB |
Output is correct |
24 |
Correct |
9 ms |
6860 KB |
Output is correct |
25 |
Correct |
7 ms |
6732 KB |
Output is correct |
26 |
Correct |
7 ms |
6732 KB |
Output is correct |
27 |
Correct |
367 ms |
88652 KB |
Output is correct |
28 |
Correct |
13 ms |
19148 KB |
Output is correct |
29 |
Correct |
11 ms |
7756 KB |
Output is correct |
30 |
Correct |
1 ms |
588 KB |
Output is correct |
31 |
Correct |
263 ms |
72180 KB |
Output is correct |
32 |
Correct |
354 ms |
89796 KB |
Output is correct |
33 |
Correct |
344 ms |
89608 KB |
Output is correct |
34 |
Correct |
323 ms |
83908 KB |
Output is correct |
35 |
Correct |
348 ms |
89648 KB |
Output is correct |
36 |
Correct |
336 ms |
89536 KB |
Output is correct |
37 |
Correct |
410 ms |
89836 KB |
Output is correct |
38 |
Correct |
233 ms |
72192 KB |
Output is correct |
39 |
Correct |
227 ms |
72020 KB |
Output is correct |