Submission #339535

#TimeUsernameProblemLanguageResultExecution timeMemory
339535ogibogi2004Cave (IOI13_cave)C++14
0 / 100
223 ms492 KiB
#include "cave.h" #include<bits/stdc++.h> using namespace std; void exploreCave(int N) { int b[N]; bool locked[N]; int s[N],d[N]; vector<int>unlocked; for(int i=0;i<N;i++) { unlocked.clear(); for(int j=0;j<N;j++) { if(!locked[j]) { b[j]=0; unlocked.push_back(j); } } int xd=tryCombination(b); if(xd==i) { int low=0,high=unlocked.size()-1,mid,ans; while(low<=high) { int mid=(low+high)/2; for(int j=0;j<unlocked.size();j++) { if(j<=mid)b[j]=0; else b[j]=1; } int r=tryCombination(b); if(r==i) { ans=mid; high=mid-1; } else low=mid+1; } b[unlocked[ans]]=1; locked[unlocked[ans]]=1; s[unlocked[ans]]=1; d[unlocked[ans]]=i; } else { int low=0,high=unlocked.size()-1,mid,ans; while(low<=high) { int mid=(low+high)/2; for(int j=0;j<unlocked.size();j++) { if(j<=mid)b[j]=1; else b[j]=0; } int r=tryCombination(b); if(r==i) { ans=mid; high=mid-1; } else low=mid+1; } b[unlocked[ans]]=0; locked[unlocked[ans]]=1; s[unlocked[ans]]=0; d[unlocked[ans]]=i; } } answer(s,d); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int j=0;j<unlocked.size();j++)
      |                 ~^~~~~~~~~~~~~~~~
cave.cpp:23:37: warning: unused variable 'mid' [-Wunused-variable]
   23 |    int low=0,high=unlocked.size()-1,mid,ans;
      |                                     ^~~
cave.cpp:51:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int j=0;j<unlocked.size();j++)
      |                 ~^~~~~~~~~~~~~~~~
cave.cpp:47:37: warning: unused variable 'mid' [-Wunused-variable]
   47 |    int low=0,high=unlocked.size()-1,mid,ans;
      |                                     ^~~
cave.cpp:40:18: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   40 |    b[unlocked[ans]]=1;
      |                  ^
cave.cpp:64:18: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   64 |    b[unlocked[ans]]=0;
      |                  ^
#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...