이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* Prof.Nicola
**/
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
template<class T>void re(T&x){cin>>x;}
template<class T1,class T2> void re(pair<T1,T2>&x){re(x.first);re(x.second);}
template<class T>void re(vector<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}}
template<class T>void re(deque<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}}
template<class T1,class T2> pair<T1,T2> mp(T1&x,T2&z){return make_pair(x,z);}
long long n,turn[5001]={};
bool ok[5001]={};
vector<long>arr;
/*long tryCombination(int arr[])
{
for(long i=0;i<n;i++){
cout<<arr[i]<<" ";
}
cout<<endl;
long x;
cin>>x;
return x;
}
*/void con(long l,long r)
{
for(long i=0;i<n;i++){
if(!ok[i]&&r>=0){
if(l){
l--;
r--;
continue;
}
arr[i]=(arr[i]^1);
r--;
}
else if(ok[i]){
arr[i]=turn[i];
}
}
}
long long ret(long x)
{
for(long i=0;i<n;i++){
if(!ok[i]){
if(x){
x--;
continue;
}
return i;
}
}
}
long long bin(long long l,long long r,long long x)
{
long long mid,z;
int a[n];
while(l<r){
mid=(l+r)/2;
con(l,mid);
for(long i=0;i<n;i++){
a[i]=arr[i];
}
z=tryCombination(a);
if(z==x){
l=mid+1;
}
else{
con(l,mid);
r=mid;
}
}
return ret(l);
}
/*answer(int a[],int b[])
{
for(long i=0;i<n;i++){
cout<<a[i]<<" ";
}
cout<<endl;
for(long i=0;i<n;i++){
cout<<b[i]<<" ";
}
cout<<endl;
}
*/void exploreCave(int N) {
n=N;
arr.resize(n);
int sw[n]={},ans[n]={},a[n];
long x;
for(long i=0;i<N;i++){
con(0,-1);
for(long i=0;i<n;i++){
a[i]=arr[i];
}
if(tryCombination(a)!=i){
con(0,N-1-i);
}
x=bin(0,N-i-1,i);
cout<<x<<endl;
ans[x]=i;
sw[x]=(arr[x]^1);
turn[x]=sw[x];
ok[x]=true;
}
answer(sw,ans);
return;
}
컴파일 시 표준 에러 (stderr) 메시지
cave.cpp: In function 'long long int ret(long int)':
cave.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
55 | }
| ^
# | 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... |