#include <bits/stdc++.h>
#define int long long
//#define double long double
#define Nanase_Kurumi_aka_menhera_chan_is_mine ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pi pair<int, int>
#define ALL(i) i.begin(),i.end()
#define gcd(i,j) __gcd(i,j)
#define fi first
#define se second
#define eps 0.00000001
#define ist insert
#define DNE nullptr
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC optimize("O2")
int max(int x,int y){return x>=y?x:y;}
int min(int x,int y){return x>=y?y:x;}
using namespace std;
typedef int ll;
const int N=3005;
const int M=1000005;
const int MOD=1000000007;//998244353;
const int INF=1000000000000000000;//2147483647;
int n,m;
string s[N];
int co[N][N],ci[N][N];
inline void sol(){
cin >>n>>m;
for (int i=0;i<n;i++)
cin >>s[i];
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
if (s[i-1][j-1]=='O')
co[i][j]++;
co[i][j]+=co[i][j-1];
}
}
for (int j=1;j<=m;j++){
for (int i=1;i<=n;i++){
if (s[i-1][j-1]=='I')
ci[i][j]++;
ci[i][j]+=ci[i-1][j];
}
}
int ans=0;
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++)
if (s[i-1][j-1]=='J')
ans+=(co[i][m]-co[i][j])*(ci[n][j]-ci[i][j]);
}
cout <<ans<<'\n';
}
signed main(){
Nanase_Kurumi_aka_menhera_chan_is_mine
int _=1;
//cin >>_;
while (_--) sol();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
416 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 |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1228 KB |
Output is correct |
8 |
Correct |
1 ms |
1356 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1188 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1356 KB |
Output is correct |
13 |
Correct |
1 ms |
1188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
416 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 |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1228 KB |
Output is correct |
8 |
Correct |
1 ms |
1356 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1188 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1356 KB |
Output is correct |
13 |
Correct |
1 ms |
1188 KB |
Output is correct |
14 |
Correct |
8 ms |
7836 KB |
Output is correct |
15 |
Correct |
3 ms |
3788 KB |
Output is correct |
16 |
Correct |
4 ms |
4684 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
7 ms |
8780 KB |
Output is correct |
19 |
Correct |
7 ms |
8616 KB |
Output is correct |
20 |
Correct |
7 ms |
8640 KB |
Output is correct |
21 |
Correct |
9 ms |
8780 KB |
Output is correct |
22 |
Correct |
7 ms |
8588 KB |
Output is correct |
23 |
Correct |
7 ms |
8636 KB |
Output is correct |
24 |
Correct |
7 ms |
8780 KB |
Output is correct |
25 |
Correct |
7 ms |
8696 KB |
Output is correct |
26 |
Correct |
9 ms |
8572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
416 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 |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1228 KB |
Output is correct |
8 |
Correct |
1 ms |
1356 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1188 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1356 KB |
Output is correct |
13 |
Correct |
1 ms |
1188 KB |
Output is correct |
14 |
Correct |
8 ms |
7836 KB |
Output is correct |
15 |
Correct |
3 ms |
3788 KB |
Output is correct |
16 |
Correct |
4 ms |
4684 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
7 ms |
8780 KB |
Output is correct |
19 |
Correct |
7 ms |
8616 KB |
Output is correct |
20 |
Correct |
7 ms |
8640 KB |
Output is correct |
21 |
Correct |
9 ms |
8780 KB |
Output is correct |
22 |
Correct |
7 ms |
8588 KB |
Output is correct |
23 |
Correct |
7 ms |
8636 KB |
Output is correct |
24 |
Correct |
7 ms |
8780 KB |
Output is correct |
25 |
Correct |
7 ms |
8696 KB |
Output is correct |
26 |
Correct |
9 ms |
8572 KB |
Output is correct |
27 |
Correct |
262 ms |
151320 KB |
Output is correct |
28 |
Correct |
12 ms |
19528 KB |
Output is correct |
29 |
Correct |
13 ms |
13824 KB |
Output is correct |
30 |
Correct |
1 ms |
844 KB |
Output is correct |
31 |
Correct |
197 ms |
125280 KB |
Output is correct |
32 |
Correct |
263 ms |
151812 KB |
Output is correct |
33 |
Correct |
262 ms |
151448 KB |
Output is correct |
34 |
Correct |
243 ms |
145080 KB |
Output is correct |
35 |
Correct |
265 ms |
151744 KB |
Output is correct |
36 |
Correct |
260 ms |
151420 KB |
Output is correct |
37 |
Correct |
300 ms |
151968 KB |
Output is correct |
38 |
Correct |
177 ms |
124700 KB |
Output is correct |
39 |
Correct |
179 ms |
124752 KB |
Output is correct |