#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int int64_t
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m; cin>>n>>m;
vector<string>v;
vector<vector<int>>orb(n+1, vector<int>(m+1));
vector<vector<int>>ing(n+1, vector<int>(m+1));
for(int i = 1; i<=n; ++i){
string a; cin>>a;
v.push_back(a);
for(int j = 1; j<=m; ++j){
char c = a[j-1];
if(c == 'O') orb[i][j] = 1 + orb[i][j-1];
if(c == 'I') ing[i][j] = 1 + ing[i-1][j];
if(!orb[i][j]) orb[i][j] = orb[i][j-1];
if(!ing[i][j]) ing[i][j] = ing[i-1][j];
}
}
/*
for(auto u: orb){
for(auto v: u) cout<<v<<" ";
cout<<endl;
}
cout<<endl;
for(auto u: ing){
for(auto v: u) cout<<v<<" ";
cout<<endl;
}
cout<<endl;
*/
int ans = 0;
for(int i = 1; i<=n; ++i){
for(int j = 1; j<=m; ++j){
int o = orb[i][m];
int in = ing[n][j];
if(v[i-1][j-1] == 'J') ans += (o-orb[i][j]) * (in - ing[i][j]);
}
}
cout<<ans;
cout<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
448 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
1 ms |
444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
448 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
1 ms |
444 KB |
Output is correct |
14 |
Correct |
6 ms |
3752 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
3 ms |
2544 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
7 ms |
4684 KB |
Output is correct |
19 |
Correct |
4 ms |
4564 KB |
Output is correct |
20 |
Correct |
4 ms |
4672 KB |
Output is correct |
21 |
Correct |
7 ms |
4692 KB |
Output is correct |
22 |
Correct |
5 ms |
4552 KB |
Output is correct |
23 |
Correct |
4 ms |
4684 KB |
Output is correct |
24 |
Correct |
7 ms |
4700 KB |
Output is correct |
25 |
Correct |
4 ms |
4524 KB |
Output is correct |
26 |
Correct |
4 ms |
4672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
448 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
1 ms |
444 KB |
Output is correct |
14 |
Correct |
6 ms |
3752 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
3 ms |
2544 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
7 ms |
4684 KB |
Output is correct |
19 |
Correct |
4 ms |
4564 KB |
Output is correct |
20 |
Correct |
4 ms |
4672 KB |
Output is correct |
21 |
Correct |
7 ms |
4692 KB |
Output is correct |
22 |
Correct |
5 ms |
4552 KB |
Output is correct |
23 |
Correct |
4 ms |
4684 KB |
Output is correct |
24 |
Correct |
7 ms |
4700 KB |
Output is correct |
25 |
Correct |
4 ms |
4524 KB |
Output is correct |
26 |
Correct |
4 ms |
4672 KB |
Output is correct |
27 |
Correct |
197 ms |
150372 KB |
Output is correct |
28 |
Correct |
1 ms |
1100 KB |
Output is correct |
29 |
Correct |
10 ms |
11724 KB |
Output is correct |
30 |
Correct |
1 ms |
716 KB |
Output is correct |
31 |
Correct |
148 ms |
110672 KB |
Output is correct |
32 |
Correct |
131 ms |
158168 KB |
Output is correct |
33 |
Correct |
121 ms |
158640 KB |
Output is correct |
34 |
Correct |
173 ms |
128412 KB |
Output is correct |
35 |
Correct |
133 ms |
158144 KB |
Output is correct |
36 |
Correct |
126 ms |
158660 KB |
Output is correct |
37 |
Correct |
216 ms |
159236 KB |
Output is correct |
38 |
Correct |
92 ms |
109940 KB |
Output is correct |
39 |
Correct |
86 ms |
110200 KB |
Output is correct |