이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <stack>
#include <map>
#include <math.h>
#include <bitset>
#include <deque>
#include <string>
#include <tuple>
#include <queue>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#define pi 3.141592653589793238
#define ll long long
#define ld long double
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define mod 998244353ll
#define INF 1000000000000000000
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define all(x) (x).begin (), (x).end ()
#define sz(x) (ll) (x).size ()
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())
#define rank rnk
#define log lg
#define fast \
ios_base::sync_with_stdio (false); \
cin.tie (NULL); \
cout.tie (NULL)
#include "cave.h"
using namespace std;
// int tryCombination(int s[])
// void answer(int s[], int d[])
void exploreCave(int n)
{
bool known[n];
rep(i,0,n-1)
known[i]=false;
int actual[n];
int binding[n];
vector <int> idx;
rep(i,0,n-1)
idx.pb(i);
rep(door,0,n-1)
{
int q[n];
for(auto x:idx)
q[x]=0;
rep(i,0,n-1)
if(known[i])
q[i]=actual[i];
int ans=tryCombination(q);
int expected;
if(ans==-1 || ans>door)
expected=0;
else
expected=1;
int lo=0;
int hi=sz(idx);
while(hi-lo!=0)
{
int mid=(lo+hi)/2;
rep(i,0,n-1)
if(known[i])
q[i]=actual[i];
rep(i,lo,mid)
q[idx[i]]=expected;
rep(i,mid+1,hi)
q[idx[i]]=1^expected;
ans=tryCombination(q);
if(ans==-1 || ans>door)
{
hi=mid;
}
else
{
lo=mid+1;
}
}
known[hi]=true;
binding[hi]=door;
actual[hi]=expected;
vector <int> nidx;
for(auto x:idx)
if(x!=hi)
nidx.pb(x);
idx=nidx;
}
answer(actual,binding);
}
// signed main()
// {
// fast;
// // freopen("milkorder.in","r",stdin);
// // freopen("milkorder.out","w",stdout);
// 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |