# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
778418 | Warinchai | 동굴 (IOI13_cave) | C++14 | 317 ms | 588 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "cave.h"
using namespace std;
int open[5005];
int cor[5005];
int n;
int a1[5005];
int a2[5005];
/*int tryCombination(int ar[]){
for(int i=0;i<n;i++){
cout<<ar[i]<<" ";
}
cout<<"input first wall:";
int x;
cin>>x;
return x;
}*/
/*int answer(int ar1[],int ar2[]){
for(int i=0;i<n;i++){
if(ar1[i]!=a1[i]){
return 0;
}
}
for(int i=0;i<n;i++){
if(ar2[i]!=a2[i]){
return 0;
}
}
return 1;
}*/
pair<int,int> find(int id){
int ans1,ans2;
int ar[n];
for(int i=0;i<n;i++){
if(open[i]!=-1){
ar[i]=open[i];
}else{
ar[i]=0;
}
}
int y=tryCombination(ar);
if(y>id||y==-1){
ans1=0;
}else{
ans1=1;
}
//cout<<"ans1:"<<ans1<<"\n";
vector<int>v;
for(int i=0;i<n;i++){
if(open[i]==-1){
v.push_back(i);
}
}
int st=0,en=v.size()-1;
while(st<en){
int m=(st+en)/2;
//cout<<"m:"<<m<<"\n";
for(int j=0;j<=v[m];j++){
if(open[j]!=-1)ar[j]=open[j];
else ar[j]=ans1;
}
for(int j=v[m]+1;j<n;j++){
if(open[j]!=-1)ar[j]=open[j];
else ar[j]=(ans1^1);
}
int x=tryCombination(ar);
if(x>id||x==-1){
ans2=v[m];
en=m-1;
}else{
st=m+1;
}
}
//cout<<"ans2:"<<ans2<<"\n";
return {ans1,ans2};
}
void exploreCave(int sz) {
//cout<<"work\n";
n=sz;
int ANS1[n];
int ANS2[n];
for(int i=0;i<n;i++){
open[i]=-1;
cor[i]=-1;
}
for(int i=0;i<n;i++){
pair<int,int>p=find(i);
open[i]=p.first;
cor[i]=p.second;
}
for(int i=0;i<n;i++){
ANS1[i]=open[i];
ANS2[i]=cor[i];
}
/*for(int i=0;i<n;i++){
cout<<ANS1[i]<<" ";
}
cout<<endl;
for(int i=0;i<n;i++){
cout<<ANS2[i]<<" ";
}*/
//cout<<endl;
answer(ANS1,ANS2);
}
/*int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>a1[i];
}
for(int i=0;i<n;i++){
cin>>a2[i];
}
exploreCave(n);
}*/
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |