제출 #778418

#제출 시각아이디문제언어결과실행 시간메모리
778418Warinchai동굴 (IOI13_cave)C++14
0 / 100
317 ms588 KiB
#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) 메시지

cave.cpp: In function 'std::pair<int, int> find(int)':
cave.cpp:75:22: warning: 'ans2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   75 |     return {ans1,ans2};
      |                      ^
#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...