제출 #348083

#제출 시각아이디문제언어결과실행 시간메모리
348083laoriu동굴 (IOI13_cave)C++14
100 / 100
847 ms748 KiB
#include <bits/stdc++.h> #include "cave.h" #define pb push_back using namespace std; const int MAX=5005; int ok[MAX]; int S[MAX],D[MAX]; void exploreCave(int n){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++)if(!D[j]) S[j]=0; else S[j]=ok[j]; int x=tryCombination(S); if(x==i){ int ans; int b=0,e=n-1; while(b<=e){ int m=b+e>>1; for(int j=0;j<n;j++)if(!D[j]) S[j]=(j<=m); else S[j]=ok[j]; int x=tryCombination(S); if(x==i)b=m+1; else{ e=m-1; ans=m; } } D[ans]=i+1; ok[ans]=1; } else{ int ans; int b=0,e=n-1; while(b<=e){ int m=b+e>>1; for(int j=0;j<n;j++)if(!D[j]) S[j]=(j>m); else S[j]=ok[j]; int x=tryCombination(S); if(x==i)b=m+1; else{ e=m-1; ans=m; } } D[ans]=i+1; ok[ans]=0; } } for(int i=0;i<n;i++) D[i]--; answer(ok,D); }

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:20:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   20 |                 int m=b+e>>1;
      |                       ~^~
cave.cpp:38:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |                 int m=b+e>>1;
      |                       ~^~
cave.cpp:50:20: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |             ok[ans]=0;
      |             ~~~~~~~^~
cave.cpp:32:20: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |             ok[ans]=1;
      |             ~~~~~~~^~
#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...