Submission #890464

#TimeUsernameProblemLanguageResultExecution timeMemory
890464SortingCave (IOI13_cave)C++17
100 / 100
178 ms816 KiB
#include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <map> #include <set> #include <queue> #include <array> #include <stack> #include <cmath> #include <iomanip> #include <cassert> #include "cave.h" using namespace std; typedef long long ll; void answer(int S[], int D[]); int tryCombination(int S[]); int s[6000], d[6000]; void exploreCave(int n){ vector<int> active(n); iota(active.begin(), active.end(), 0); for(int i = 0; i < n; ++i){ int l = 0, r = (int)active.size() - 1; for(int x: active) s[x] = 0; int prv = tryCombination(s); while(l != r){ int mid = (l + r) >> 1; for(int i = 0; i <= mid; ++i) s[active[i]] = 1; for(int i = mid + 1; i < active.size(); ++i) s[active[i]] = 0; if((tryCombination(s) == i) != (prv == i)){ r = mid; } else{ l = mid + 1; } } int key = active[l]; active.erase(find(active.begin(), active.end(), key)); if(prv == i){ s[key] = 1; } else{ s[key] = 0; } d[key] = i; } answer(s, d); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:40:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             for(int i = mid + 1; i < active.size(); ++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...