#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define int long long
using namespace std;
const int nx=3005;
char mp[nx][nx];
int32_t main(){
cin.tie(NULL)->sync_with_stdio(false);
int n,m; cin >> n >> m;
for(int i=1 ; i<=n ; i++){
string s; cin >> s;
for(int j=1 ; j<=m ; j++){
mp[i][j]=s[j-1];
}
}
vector<int> aj[nx],ao[nx],ai[nx];
for(int i=1 ; i<=n ; i++){
for(int j=1 ; j<=m ; j++){
if(mp[i][j]=='J'){
aj[i].push_back(j);
}
else if(mp[i][j]=='O'){
ao[j].push_back(i);
}
else if(mp[i][j]=='I'){
ai[j].push_back(i);
}
}
}
int ans=0;
for(int l=1 ; l<=m ; l++)/*loop l*/{
for(int i:ao[l])/*loop i*/{
for(int j:aj[i])/*loop j*/{
if(j>=l) continue;
for(int k:ai[j])/*loop k*/{
if(k<=i) continue;
ans++;
}
}
}
}
/* i j k l
i<k
j<l
*/
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
856 KB |
Output is correct |
7 |
Correct |
2 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
1116 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
1120 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
856 KB |
Output is correct |
7 |
Correct |
2 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
1116 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
1120 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
173 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
1884 KB |
Output is correct |
16 |
Correct |
15 ms |
2908 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
322 ms |
5764 KB |
Output is correct |
19 |
Correct |
25 ms |
4952 KB |
Output is correct |
20 |
Correct |
627 ms |
4460 KB |
Output is correct |
21 |
Correct |
322 ms |
5720 KB |
Output is correct |
22 |
Correct |
48 ms |
4952 KB |
Output is correct |
23 |
Correct |
625 ms |
4460 KB |
Output is correct |
24 |
Correct |
288 ms |
4952 KB |
Output is correct |
25 |
Correct |
19 ms |
4700 KB |
Output is correct |
26 |
Correct |
610 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
856 KB |
Output is correct |
7 |
Correct |
2 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
1116 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
1120 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
173 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
1884 KB |
Output is correct |
16 |
Correct |
15 ms |
2908 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
322 ms |
5764 KB |
Output is correct |
19 |
Correct |
25 ms |
4952 KB |
Output is correct |
20 |
Correct |
627 ms |
4460 KB |
Output is correct |
21 |
Correct |
322 ms |
5720 KB |
Output is correct |
22 |
Correct |
48 ms |
4952 KB |
Output is correct |
23 |
Correct |
625 ms |
4460 KB |
Output is correct |
24 |
Correct |
288 ms |
4952 KB |
Output is correct |
25 |
Correct |
19 ms |
4700 KB |
Output is correct |
26 |
Correct |
610 ms |
4444 KB |
Output is correct |
27 |
Execution timed out |
1102 ms |
104528 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |