#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define ll long long
#define pri pair<int,int>
#define prl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define vpl vector<pair<ll,ll>>
#define re return 0
#define sqrt sqrtl
#define int ll
int32_t main() {
int h,w;cin>>h>>w;
vector<vector<int>> no(h,vector<int>(w));
vector<vector<int>> ni(w,vector<int>(h));
vector<string> grid(h);
for (int i = 0;i<h;i++) {
string s;cin>>s;
for (int j = 0;j<w;j++) {
if (j==0) no[i][j] = (s[j]=='O');
else no[i][j] = no[i][j-1] + (s[j]=='O');
if (i==0) ni[j][i] = (s[j]=='I');
else ni[j][i] = ni[j][i-1]+(s[j]=='I');
}
grid[i] = s;
}
int s = 0;
for (int i = 0;i<h;i++) {
for (int j = 0;j<w;j++) {
if (grid[i][j]!='J') continue;
s+= (no[i][w-1] - no[i][j]) * (ni[j][h-1] - ni[j][i]);
//cout<<no[i][j]<<" ";
}//cout<<endl;
}
cout<<s<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
5 ms |
3676 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
7 ms |
4444 KB |
Output is correct |
19 |
Correct |
6 ms |
4440 KB |
Output is correct |
20 |
Correct |
6 ms |
4444 KB |
Output is correct |
21 |
Correct |
7 ms |
4784 KB |
Output is correct |
22 |
Correct |
6 ms |
4700 KB |
Output is correct |
23 |
Correct |
6 ms |
4680 KB |
Output is correct |
24 |
Correct |
7 ms |
4700 KB |
Output is correct |
25 |
Correct |
6 ms |
4628 KB |
Output is correct |
26 |
Correct |
6 ms |
4700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
5 ms |
3676 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
7 ms |
4444 KB |
Output is correct |
19 |
Correct |
6 ms |
4440 KB |
Output is correct |
20 |
Correct |
6 ms |
4444 KB |
Output is correct |
21 |
Correct |
7 ms |
4784 KB |
Output is correct |
22 |
Correct |
6 ms |
4700 KB |
Output is correct |
23 |
Correct |
6 ms |
4680 KB |
Output is correct |
24 |
Correct |
7 ms |
4700 KB |
Output is correct |
25 |
Correct |
6 ms |
4628 KB |
Output is correct |
26 |
Correct |
6 ms |
4700 KB |
Output is correct |
27 |
Correct |
282 ms |
150436 KB |
Output is correct |
28 |
Correct |
1 ms |
860 KB |
Output is correct |
29 |
Correct |
16 ms |
11936 KB |
Output is correct |
30 |
Correct |
1 ms |
860 KB |
Output is correct |
31 |
Correct |
195 ms |
110792 KB |
Output is correct |
32 |
Correct |
248 ms |
158240 KB |
Output is correct |
33 |
Correct |
255 ms |
158692 KB |
Output is correct |
34 |
Correct |
224 ms |
128424 KB |
Output is correct |
35 |
Correct |
265 ms |
158404 KB |
Output is correct |
36 |
Correct |
249 ms |
158544 KB |
Output is correct |
37 |
Correct |
307 ms |
159236 KB |
Output is correct |
38 |
Correct |
168 ms |
109872 KB |
Output is correct |
39 |
Correct |
170 ms |
110184 KB |
Output is correct |