이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 10000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL
const int N = 5005;
int sig[N];
int a[N];
int bb[N];
int nn;
/*int tryCombination(int a[])
{
for(int i = 0;i<nn;i++) cout<<a[i]<<" ";
cout<<endl;
int x;
cin>>x;
return x;
}
void answer(int a[], int b[])
{
for(int i = 0;i<nn;i++) cout<<a[i]<<" "<<b[i]<<endl;
}*/
void exploreCave(int n)
{
nn = n;
for(int i = 0;i<n;i++) sig[i] = -1;
for(int b = 1;b<=n;b++)
{
for(int i = 0;i<n;i++) if(sig[i]!=-1) a[i] = sig[i]; else a[i] = 1;
int x = tryCombination(a);
if(x==-1) x = n;
if(x>=b) x = 1;
else x = 0;
int l = 0;
int r = n-1;
while(l<r)
{
int mid = (l+r)/2;
for(int i = 0;i<n;i++) if(sig[i]!=-1) a[i] = sig[i]; else a[i] = 1;
for(int i = l;i<=mid;i++) if(sig[i]!=-1) a[i] = sig[i]; else a[i] = 1;
for(int i = mid+1;i<=r;i++) if(sig[i]!=-1) a[i] = sig[i]; else a[i] = 0;
int w = tryCombination(a);
if(x)
{
if(w>=b)
{
r = mid;
}
else
{
l = mid + 1;
}
}
else
{
if(w<b)
{
r = mid;
}
else
{
l = mid + 1;
}
}
}
//cout<<l<<" "<<x<<endl;
sig[l] = x;
bb[l] = b-1;
}
answer(sig, bb);
}
# | 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... |