이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cave.h"
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=5005;
int pom[MAX],perm[MAX],arr[MAX];
bool O[MAX];
void get(int n)
{
for (int i=0;i<n;i++)pom[i]=arr[i];
}
void exploreCave(int n)
{
for (int i=0;i<n;i++)arr[i]=-1,perm[i]=-1;
vi pos;
int x=0;
for (int door=0;door<n;door++)
{
pos.clear();
get(n);
for (int i=0;i<n;i++) if (arr[i]==-1)pos.pb(i);
int bit=1;
for (int i=0;i<n;i++) if (arr[i]==-1)pom[i]=1;
int y=tryCombination(pom);
if (y<=x)bit^=1;
int ile=sz(pos);
int ip=-1,ik=sz(pos)-1;
while (ip+1<ik)
{
int mid=(ip+ik)>>1;
get(n);
for (int i=0;i<=mid;i++)pom[pos[i]]=bit;
for (int i=mid+1;i<sz(pos);i++)pom[pos[i]]=bit^1;
y=tryCombination(pom);
if (y>x)ik=mid;
else ip=mid;
}
ip=pos[ip+1];
/*
if (ip<0 || ip>=n || O[ip])
{
while(true)x++;
}
O[ip]=true;
*/
assert(ip==door);
perm[ip]=door,arr[ip]=bit;
x++;
}
answer(arr,perm);
}
컴파일 시 표준 에러 (stderr) 메시지
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:38:8: warning: unused variable 'ile' [-Wunused-variable]
int ile=sz(pos);
^~~
# | 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... |