Submission #576249

#TimeUsernameProblemLanguageResultExecution timeMemory
576249AugustinasJucasUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms504 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; int n; string nl; vector<int> ans; vector<int> nera(vector<int> a ) { vector<int> ret; set<int> setas; for(auto &x : a) setas.insert(x); for(int i = 0; i < n; i++) { if(setas.count(i) == 0) ret.push_back(i); } return ret; } string nr(vector<int> x ) { string ret = nl; for(auto &y : x) ret[y] = '1'; return ret; } void darom(vector<int> mas) { if(mas.size() == 1) return ; vector<int> a, b; for(int i = 0; i < mas.size()/2; i++) { a.push_back(mas[i]); b.push_back(mas[i+mas.size()/2]); } string s = nr(nera(mas)); for(auto &x : b) { s[x] = '1'; add_element(s); s[x] = '0'; } darom(a); darom(b); } int sk = 0; void rask(vector<int> mas) { if(mas.size() == 1) { ans[mas[0]] = sk; return ; } string s = nr(nera(mas)); vector<int> a, b; for(auto &x : mas){ s[x] = '1'; if(check_element(s) == 1) { a.push_back(x); }else { b.push_back(x); } s[x] = '0'; } sk = sk * 2 + 1; rask(a); sk--; rask(b); sk /= 2; } vector<int> restore_permutation(int N, int w, int r) { /* add_element("0"); compile_set(); check_element("0"); */ n = N; ans.resize(n); for(int i = 0; i < n; i++) nl.push_back('0'); vector<int> ms; for(int i = 0; i < n; i++) ms.push_back(i); darom(ms); compile_set(); rask(ms); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void darom(std::vector<int>)':
messy.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 0; i < mas.size()/2; 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...