#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 1e9 + 7;
int n, m, t[7][3003][3003]; ll ans;
int get(char c){
if(c=='J') return 1;
else if(c=='I') return 2;
else if(c=='O') return 3;
}
int32_t main(){
ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
cin>>n>>m;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
char c;
cin>>c;
t[0][i][j]=get(c);
for(int idx=1; idx<=3; idx++) t[idx][i][j]=t[idx][i][j-1];
for(int idx=4; idx<=6; idx++) t[idx][i][j]=t[idx][i-1][j];
t[get(c)][i][j]++;
t[get(c)+3][i][j]++;
}
}
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
if(t[0][i][j]==1) ans+=1LL*(t[3][i][m]-t[3][i][j])*(t[5][n][j]-t[5][i][j]);
}
}
cout<<ans;
}
Compilation message
joi2019_ho_t1.cpp: In function 'int get(char)':
joi2019_ho_t1.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
3448 KB |
Output is correct |
6 |
Correct |
5 ms |
3448 KB |
Output is correct |
7 |
Correct |
5 ms |
3192 KB |
Output is correct |
8 |
Correct |
5 ms |
3448 KB |
Output is correct |
9 |
Correct |
5 ms |
3320 KB |
Output is correct |
10 |
Correct |
5 ms |
3192 KB |
Output is correct |
11 |
Correct |
5 ms |
3448 KB |
Output is correct |
12 |
Correct |
5 ms |
3448 KB |
Output is correct |
13 |
Correct |
5 ms |
3064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
3448 KB |
Output is correct |
6 |
Correct |
5 ms |
3448 KB |
Output is correct |
7 |
Correct |
5 ms |
3192 KB |
Output is correct |
8 |
Correct |
5 ms |
3448 KB |
Output is correct |
9 |
Correct |
5 ms |
3320 KB |
Output is correct |
10 |
Correct |
5 ms |
3192 KB |
Output is correct |
11 |
Correct |
5 ms |
3448 KB |
Output is correct |
12 |
Correct |
5 ms |
3448 KB |
Output is correct |
13 |
Correct |
5 ms |
3064 KB |
Output is correct |
14 |
Correct |
28 ms |
19676 KB |
Output is correct |
15 |
Correct |
14 ms |
12408 KB |
Output is correct |
16 |
Correct |
16 ms |
11256 KB |
Output is correct |
17 |
Correct |
2 ms |
760 KB |
Output is correct |
18 |
Correct |
31 ms |
21240 KB |
Output is correct |
19 |
Correct |
28 ms |
20984 KB |
Output is correct |
20 |
Correct |
28 ms |
20856 KB |
Output is correct |
21 |
Correct |
31 ms |
21496 KB |
Output is correct |
22 |
Correct |
28 ms |
21240 KB |
Output is correct |
23 |
Correct |
28 ms |
21112 KB |
Output is correct |
24 |
Correct |
31 ms |
21496 KB |
Output is correct |
25 |
Correct |
28 ms |
21240 KB |
Output is correct |
26 |
Correct |
28 ms |
21112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
3448 KB |
Output is correct |
6 |
Correct |
5 ms |
3448 KB |
Output is correct |
7 |
Correct |
5 ms |
3192 KB |
Output is correct |
8 |
Correct |
5 ms |
3448 KB |
Output is correct |
9 |
Correct |
5 ms |
3320 KB |
Output is correct |
10 |
Correct |
5 ms |
3192 KB |
Output is correct |
11 |
Correct |
5 ms |
3448 KB |
Output is correct |
12 |
Correct |
5 ms |
3448 KB |
Output is correct |
13 |
Correct |
5 ms |
3064 KB |
Output is correct |
14 |
Correct |
28 ms |
19676 KB |
Output is correct |
15 |
Correct |
14 ms |
12408 KB |
Output is correct |
16 |
Correct |
16 ms |
11256 KB |
Output is correct |
17 |
Correct |
2 ms |
760 KB |
Output is correct |
18 |
Correct |
31 ms |
21240 KB |
Output is correct |
19 |
Correct |
28 ms |
20984 KB |
Output is correct |
20 |
Correct |
28 ms |
20856 KB |
Output is correct |
21 |
Correct |
31 ms |
21496 KB |
Output is correct |
22 |
Correct |
28 ms |
21240 KB |
Output is correct |
23 |
Correct |
28 ms |
21112 KB |
Output is correct |
24 |
Correct |
31 ms |
21496 KB |
Output is correct |
25 |
Correct |
28 ms |
21240 KB |
Output is correct |
26 |
Correct |
28 ms |
21112 KB |
Output is correct |
27 |
Correct |
555 ms |
255460 KB |
Output is correct |
28 |
Correct |
66 ms |
66428 KB |
Output is correct |
29 |
Correct |
38 ms |
22392 KB |
Output is correct |
30 |
Correct |
4 ms |
1272 KB |
Output is correct |
31 |
Correct |
439 ms |
212188 KB |
Output is correct |
32 |
Correct |
497 ms |
255992 KB |
Output is correct |
33 |
Correct |
476 ms |
255148 KB |
Output is correct |
34 |
Correct |
500 ms |
246220 KB |
Output is correct |
35 |
Correct |
531 ms |
256068 KB |
Output is correct |
36 |
Correct |
478 ms |
255216 KB |
Output is correct |
37 |
Correct |
578 ms |
255972 KB |
Output is correct |
38 |
Correct |
389 ms |
212272 KB |
Output is correct |
39 |
Correct |
346 ms |
211320 KB |
Output is correct |