제출 #338913

#제출 시각아이디문제언어결과실행 시간메모리
338913NicolaAbusaad2014동굴 (IOI13_cave)C++14
0 / 100
876 ms856 KiB
/** * Prof.Nicola **/ #include "cave.h" #include <bits/stdc++.h> using namespace std; template<class T>void re(T&x){cin>>x;} template<class T1,class T2> void re(pair<T1,T2>&x){re(x.first);re(x.second);} template<class T>void re(vector<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}} template<class T>void re(deque<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}} template<class T1,class T2> pair<T1,T2> mp(T1&x,T2&z){return make_pair(x,z);} long long n,turn[5001]={}; bool ok[5001]={}; vector<long>arr; /*long tryCombination(int arr[]) { for(long i=0;i<n;i++){ cout<<arr[i]<<" "; } cout<<endl; long x; cin>>x; return x; } */void con(long l,long r) { for(long i=0;i<n;i++){ if(!ok[i]&&r>=0){ if(l){ l--; r--; continue; } arr[i]=(arr[i]^1); r--; } else if(ok[i]){ arr[i]=turn[i]; } } } long long ret(long x) { for(long i=0;i<n;i++){ if(!ok[i]){ if(x){ x--; continue; } return i; } } } long long bin(long long l,long long r,long long x) { long long mid,z; int a[n]; while(l<r){ mid=(l+r)/2; con(l,mid); for(long i=0;i<n;i++){ a[i]=arr[i]; } z=tryCombination(a); if(z==x){ l=mid+1; } else{ con(l,mid); r=mid; } } return ret(l); } /*answer(int a[],int b[]) { for(long i=0;i<n;i++){ cout<<a[i]<<" "; } cout<<endl; for(long i=0;i<n;i++){ cout<<b[i]<<" "; } cout<<endl; } */void exploreCave(int N) { n=N; arr.resize(n); int sw[n]={},ans[n]={},a[n]; long x; for(long i=0;i<N;i++){ con(0,-1); for(long i=0;i<n;i++){ a[i]=arr[i]; } if(tryCombination(a)!=i){ con(0,N-1-i); } x=bin(0,N-i-1,i); cout<<x<<endl; ans[x]=i; sw[x]=(arr[x]^1); turn[x]=sw[x]; ok[x]=true; } answer(sw,ans); return; }

컴파일 시 표준 에러 (stderr) 메시지

cave.cpp: In function 'long long int ret(long int)':
cave.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...