이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
/*int tryCombination(int arr[]){
int ttmp=4;
for(int i=0;i<ttmp;i++) cout<<arr[i] <<" ";
cout<<"\n";
int s;
cin>>s;
return s;
}*/
void exploreCave(int N) {
int arr[N],fix[N],cn[N],cp[N];
for(int i=0;i<N;i++) arr[i]=fix[i]=cn[i]=0;
int con[N];
vector<int> v;
for(int i=0;i<N;i++){
v.clear();
for(int j=0;j<N;j++){
if(fix[j]) continue;
v.push_back(arr[j]);
con[v.size()-1]=j;
}
int l=0,r=v.size()-1;
while(l<r){
int mid=(l+r)/2;
for(int j=mid+1;j<=r;j++) v[j]=-1;
for(int j=l;j<=mid;j++) v[j]=0;
for(int j=0;j<N;j++) cp[j]=arr[j];
for(int j=0;j<v.size();j++) cp[con[j]]=v[j];
int tmp=tryCombination(cp);
if(tmp==-1) tmp=INT_MAX;
if(tmp>i){
r=mid;
if(l==r) fix[con[l]]=1,cn[con[l]]=i,arr[con[l]]=0;
continue;
}
for(int j=l;j<=mid;j++) v[j]=1;
for(int j=0;j<N;j++) cp[j]=arr[j];
for(int j=0;j<v.size();j++) cp[con[j]]=v[j];
tmp=tryCombination(cp);
if(tmp==-1) tmp=INT_MAX;
if(tmp>i){
r=mid;
if(l==r) fix[con[l]]=1,cn[con[l]]=i,arr[con[l]]=1;
continue;
}
for(int j=l;j<=mid;j++) v[j]=-1;
for(int j=mid+1;j<=r;j++) v[j]=0;
for(int j=0;j<N;j++) cp[j]=arr[j];
for(int j=0;j<v.size();j++) cp[con[j]]=v[j];
tmp=tryCombination(cp);
if(tmp==-1) tmp=INT_MAX;
if(tmp>i){
l=mid+1;
if(l==r) fix[con[l]]=1,cn[con[l]]=i,arr[con[l]]=0;
continue;
}
l=mid+1;
if(l==r) fix[con[l]]=1,cn[con[l]]=i,arr[con[l]]=1;
}
if(i==N-1){
for(int j=0;j<N;j++){
if(!fix[j]){
cn[j]=i;
arr[j]=0;
if(tryCombination(arr)==-1) break;
else{
arr[j]=1;
break;
}
}
}
}
}
/*cout<<endl <<endl <<endl;
for(int i=0;i<N;i++) cout<<arr[i] <<" ";
for(int i=0;i<N;i++) cout<<cn[i] <<" ";*/
answer(arr,cn);
}
/*int main(){
exploreCave(4);
}*/
컴파일 시 표준 에러 (stderr) 메시지
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int j=0;j<v.size();j++) cp[con[j]]=v[j];
| ~^~~~~~~~~
cave.cpp:40:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(int j=0;j<v.size();j++) cp[con[j]]=v[j];
| ~^~~~~~~~~
cave.cpp:51:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | for(int j=0;j<v.size();j++) cp[con[j]]=v[j];
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |