#include<bits/stdc++.h>
using namespace std;
const int N=3001;
int n,m;
int cnt;
bool vis[N][N];
string arr[N],s;
vector<int>i,j,k,l;
map<vector<int>,bool>mp;
int main(){
ios_base::sync_with_stdio(0),cin.tie(0);
int n,m;
cin >> n >> m;
for(int y=1; y<=n; y++){
cin >> s;
arr[y]="x"+s;
for(int x=1; x<=m; x++){
if(arr[y][x]=='J'){
i.push_back(y);
j.push_back(x);
}
else if(arr[y][x]=='O'){
i.push_back(y);
l.push_back(x);
}
else if(arr[y][x]=='I'){
k.push_back(y);
j.push_back(x);
}
}
}
for(int ii:i){
for(int jj:j){
if(arr[ii][jj]=='J'){
for(int ll:l){
if(arr[ii][ll]=='O'){
for(int kk:k){
if(arr[kk][jj]=='I'){
vector<int>chk;
chk.push_back(ii);chk.push_back(jj);chk.push_back(kk);chk.push_back(ll);
if(!mp[chk]&&ii<kk&&jj<ll){
cnt++;
mp[chk]=true;
}
}
}
}
}
}
}
}
cout << cnt;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
8 ms |
340 KB |
Output is correct |
5 |
Execution timed out |
1095 ms |
1292 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
8 ms |
340 KB |
Output is correct |
5 |
Execution timed out |
1095 ms |
1292 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
8 ms |
340 KB |
Output is correct |
5 |
Execution timed out |
1095 ms |
1292 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |