이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 kk:k){
for(int ll:l){
for(int ii:i){
if(arr[ii][ll]=='O'&&!vis[ii][ll]){
for(int jj:j){
if(arr[kk][jj]=='I'&&!vis[kk][jj]){
if(arr[ii][jj]=='J'&&ii>=jj){
vis[ii][jj]=true;vis[ii][ll]=true;
vector<int>chk;
chk.push_back(ii);chk.push_back(jj);chk.push_back(kk);chk.push_back(ll);
if(!mp[chk]){
cnt++;
mp[chk]=true;
}
}
}
}
}
}
}
}
cout << cnt;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |