Submission #289922

#TimeUsernameProblemLanguageResultExecution timeMemory
289922Atill83Cave (IOI13_cave)C++14
100 / 100
318 ms760 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; const int MAXN = (int) 5e3 + 5; int s[MAXN]; int ans[MAXN]; vector<int> rest; int D[MAXN]; void ot(int N){ for(int i = 0; i < N; i++) cerr<<s[i]<<" "; cerr<<endl; } void exploreCave(int N) { /* ... */ for(int i = 0; i < N; i++) rest.push_back(i); for(int i = 0; i < N; i++){ bool st = 1; for(int j = 0; j < rest.size(); j++){ s[rest[j]] = 0; } int ans = tryCombination(s); if(ans == -1 || ans > i){ st = 0; } int l = 0, r = rest.size() - 1; while(l < r){ int m = (l + r) / 2; for(int j = l; j <= m; j++){ s[rest[j]] = st; } for(int j = m + 1; j <= r; j++) s[rest[j]] = !st; //cerr<<l<<" "<<r<<endl; //ot(N); int ans = tryCombination(s); if(ans == -1 || ans > i){ r = m; }else{ l = m + 1; } } //cerr<<st<<endl; //cerr<<rest[l]<<" "<<i<<endl; //ot(N); s[rest[l]] = st; D[rest[l]] = i; swap(rest[l], rest.back()); rest.pop_back(); } answer(s, D); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:20:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for(int j = 0; j < rest.size(); j++){
      |                        ~~^~~~~~~~~~~~~
#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...