#include <bits/stdc++.h>
using namespace std;
const int nx=3005;
char mp[nx][nx];
int 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;
/*cout << "adj J" << '\n';
for(int i=1 ; i<=n ; i++){
cout << "i= " << i << " ";
for(int j:aj[i]){
cout << j << ' ';
}
cout << '\n';
}
cout << "adj O" << '\n';
for(int i=1 ; i<=m ; i++){
cout << "i= " << i << " ";
for(int j:ao[i]){
cout << j << ' ';
}
cout << '\n';
}
cout << "adj I" << '\n';
for(int i=1 ; i<=m ; i++){
cout << "i= " << i << " ";
for(int j:ai[i]){
cout << j << ' ';
}
cout << '\n';
}*/
for(int u1=1 ; u1<=m ; u1++)/*loop l*/{
for(int v1:ao[u1])/*loop i*/{
for(int v2:aj[v1])/*loop j*/{
if(v2>=u1) continue;
for(int v3:ai[v2])/*loop k*/{
if(v3<=v1) continue;
ans++;
}
}
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
4 ms |
792 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
4 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
4 ms |
1008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
4 ms |
792 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
4 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
4 ms |
1008 KB |
Output is correct |
14 |
Correct |
490 ms |
3432 KB |
Output is correct |
15 |
Correct |
2 ms |
1884 KB |
Output is correct |
16 |
Correct |
30 ms |
2140 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
833 ms |
3676 KB |
Output is correct |
19 |
Correct |
76 ms |
3420 KB |
Output is correct |
20 |
Execution timed out |
1078 ms |
3164 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
4 ms |
792 KB |
Output is correct |
8 |
Correct |
2 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
4 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
4 ms |
1008 KB |
Output is correct |
14 |
Correct |
490 ms |
3432 KB |
Output is correct |
15 |
Correct |
2 ms |
1884 KB |
Output is correct |
16 |
Correct |
30 ms |
2140 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
833 ms |
3676 KB |
Output is correct |
19 |
Correct |
76 ms |
3420 KB |
Output is correct |
20 |
Execution timed out |
1078 ms |
3164 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |