제출 #267131

#제출 시각아이디문제언어결과실행 시간메모리
267131DavidDamianLibrary (JOI18_library)C++11
19 / 100
3063 ms384 KiB
#include<bits/stdc++.h> #include "library.h" ///Subtask 1 ///Discover from the edges (start and end) using namespace std; void Solve(int N) { vector<int> full(N,1); vector<int> Empty(N,0); vector<int> ans(N,0); vector<int> found(N+1,0); if(N==1){ Answer(full); return; } int L=0; int id_L=0; int id_R=N-1; for(int n=1;n<N;n++){ for(int i=1;i<=N;i++){ if(found[i]) continue; full[i-1]=0; int cost=Query(full); if(cost==1){ if(L==0){ L=i; ans[0]=i; id_L++; } else{ Empty[L-1]=1; Empty[i-1]=1; cost=Query(Empty); if(cost==1){ ans[id_L++]=i; L=i; } else{ ans[id_R--]=i; } Empty[L-1]=0; Empty[i-1]=0; } found[i]=1; break; } else full[i-1]=1; } } int remain=0; for(int i=1;i<=N;i++){ if(!found[i]) remain=i; } for(int i=0;i<N;i++){ if(ans[i]==0) ans[i]=remain; } Answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...