#include <bits/stdc++.h>
using namespace std;
#define cin(vec) for(auto& i : vec) cin >> i
#define cout(vec) for(auto& i : vec) cout << i << " "; cout << "\n";
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define loop(i,a,b) for (int i = a; i < b; i++)
#define F first
#define S second
#define pb(n) push_back(n)
#define pf(n) push_front(n)
#define dci(d) fixed<<setprecision(d)
#define sp ' '
#define el '\n'
#define all(v) v.begin(),v.end()
#define int long long
int dx[8]= {0,0,1,-1,-1,1,1,-1};
int dy[8]= {-1,1,0,0,-1,1,-1,1};
int const N=1e4+5,M=1e3+1,Mod=1e9+7;
void testcase(int h){
int n,m;cin>>n>>m;
char c[n][m];
map<char,vector<pair<int,int>>>loc;
for(int i=0;i<n;i++){
string s;cin>>s;
for(int j=0;j<m;j++){
c[i][j]=s[j];
}
}
int I[m]={};
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
I[j]+=c[i][j]=='I';
}
}
int o[n]={};
for(int j=0;j<m;j++){
for(int i=0;i<n;i++){
o[i]+=c[i][j]=='O';
}
}
// cout(I);cout(o);
int ans=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
o[i]-=c[i][j]=='O';
if(c[i][j]=='J'){
ans+=o[i]*I[j];
}
I[j]-=c[i][j]=='I';
}
}
cout<<ans<<el;
}
int32_t main()
{
// fast
testcase(1);
// int tc;cin>>tc;for(int i=1;i<=tc;i++)testcase(i);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
300 KB |
Output is correct |
10 |
Correct |
1 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
300 KB |
Output is correct |
10 |
Correct |
1 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
14 |
Correct |
6 ms |
568 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
300 KB |
Output is correct |
18 |
Correct |
9 ms |
780 KB |
Output is correct |
19 |
Correct |
8 ms |
764 KB |
Output is correct |
20 |
Correct |
7 ms |
724 KB |
Output is correct |
21 |
Correct |
8 ms |
692 KB |
Output is correct |
22 |
Correct |
6 ms |
696 KB |
Output is correct |
23 |
Correct |
7 ms |
696 KB |
Output is correct |
24 |
Correct |
8 ms |
724 KB |
Output is correct |
25 |
Correct |
7 ms |
724 KB |
Output is correct |
26 |
Correct |
7 ms |
776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
300 KB |
Output is correct |
10 |
Correct |
1 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
14 |
Correct |
6 ms |
568 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
300 KB |
Output is correct |
18 |
Correct |
9 ms |
780 KB |
Output is correct |
19 |
Correct |
8 ms |
764 KB |
Output is correct |
20 |
Correct |
7 ms |
724 KB |
Output is correct |
21 |
Correct |
8 ms |
692 KB |
Output is correct |
22 |
Correct |
6 ms |
696 KB |
Output is correct |
23 |
Correct |
7 ms |
696 KB |
Output is correct |
24 |
Correct |
8 ms |
724 KB |
Output is correct |
25 |
Correct |
7 ms |
724 KB |
Output is correct |
26 |
Correct |
7 ms |
776 KB |
Output is correct |
27 |
Correct |
275 ms |
16932 KB |
Output is correct |
28 |
Correct |
2 ms |
340 KB |
Output is correct |
29 |
Correct |
17 ms |
1492 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
184 ms |
12548 KB |
Output is correct |
32 |
Correct |
288 ms |
17740 KB |
Output is correct |
33 |
Correct |
254 ms |
18004 KB |
Output is correct |
34 |
Correct |
226 ms |
14520 KB |
Output is correct |
35 |
Correct |
268 ms |
17860 KB |
Output is correct |
36 |
Correct |
280 ms |
17888 KB |
Output is correct |
37 |
Correct |
290 ms |
17908 KB |
Output is correct |
38 |
Correct |
166 ms |
12368 KB |
Output is correct |
39 |
Correct |
175 ms |
12508 KB |
Output is correct |