제출 #58068

#제출 시각아이디문제언어결과실행 시간메모리
58068naderjemel동굴 (IOI13_cave)C++14
100 / 100
467 ms640 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; int s[5000],ss[5000],d[5000]; void exploreCave(int N) { for(int i=0;i<N;i++){ s[i]=0; d[i]=-1; } bool done[5005]; memset(done,false,sizeof(done)); for(int i=0;i<N;i++){ int lo=0,hi=N-1; int rs; int r=tryCombination(s); if(r==i){ // it opens with 1 while(lo<=hi){ int mid=(lo+hi)>>1; for(int j=mid;j<N;j++) ss[j]=s[j]; for(int j=lo;j<=mid;j++){ if(done[j]) ss[j]=s[j]; else ss[j]=1; } int rr=tryCombination(ss); if(rr==i){ lo=mid+1; } else{ hi=mid-1; rs=mid; } } d[rs]=i; done[rs]=true; s[rs]=1; } else{ // it opens with 0 while(lo<=hi){ int mid=(lo+hi)>>1; for(int j=mid;j<N;j++) ss[j]=s[j]; for(int j=lo;j<=mid;j++){ if(done[j]) ss[j]=s[j]; else ss[j]=1; } int rr=tryCombination(ss); if(rr==i){ hi=mid-1; rs=mid; } else{ lo=mid+1; } } d[rs]=i; done[rs]=true; s[rs]=0; } } answer(s,d); }

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:35:12: warning: 'rs' may be used uninitialized in this function [-Wmaybe-uninitialized]
       d[rs]=i;
       ~~~~~^~
#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...