Submission #285019

#TimeUsernameProblemLanguageResultExecution timeMemory
285019user202729Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms640 KiB
// moreflags=grader.cpp #include <vector> // 15 // (somehow the wrong solution breaks at the sample solution... and I didn't notice it!?) #include "messy.h" #if not LOCAL #define NDEBUG 1 #endif #include<cassert> template<bool write> std::vector<int> process(int n, std::vector<int> a, std::vector<int> pivot){ auto const sizea=(int)a.size(); auto const numBit=__builtin_ctz(sizea); assert(sizea==(1<<numBit)); if(sizea==1) return a; auto const half=sizea>>1; if(write){ std::vector<int> first(a.begin(), a.begin()+half), sec(a.begin()+half, a.end()); for(auto it: first){ std::string tmp(n,'0'); for(auto it: pivot) tmp[it]='1'; tmp[it]='1'; add_element(std::move(tmp)); } process<true>(n, first, sec); process<true>(n, sec, first); return {}; }else{ std::vector<int> first, sec; for(auto it: a){ std::string tmp(n,'0'); for(auto it: pivot) tmp[it]='1'; tmp[it]='1'; if(check_element(std::move(tmp))) first.push_back(it); else sec.push_back(it); } assert((int)first.size()==half); assert((int)sec.size()==half); auto result=process<false>(n, first, sec); auto result2=process<false>(n, sec, first); result.insert(result.end(),begin(result2), end(result2)); return result; } } std::vector<int> restore_permutation(int n, int w, int r) { std::vector<int> all(n); for(int i=0; i<n; ++i) all[i]=i; process<true>(n, all,{}); compile_set(); auto const result1=process<false>(n, std::move(all),{}); std::vector<int> result(n); for(int index=0; index<n; ++index) result[result1[index]]=index; return result; }

Compilation message (stderr)

messy.cpp: In instantiation of 'std::vector<int> process(int, std::vector<int>, std::vector<int>) [with bool write = true]':
messy.cpp:55:25:   required from here
messy.cpp:14:13: warning: unused variable 'numBit' [-Wunused-variable]
   14 |  auto const numBit=__builtin_ctz(sizea);
      |             ^~~~~~
messy.cpp: In instantiation of 'std::vector<int> process(int, std::vector<int>, std::vector<int>) [with bool write = false]':
messy.cpp:57:56:   required from here
messy.cpp:14:13: warning: unused variable 'numBit' [-Wunused-variable]
#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...