Submission #411619

#TimeUsernameProblemLanguageResultExecution timeMemory
411619nxteruUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms460 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; vector<int>ans; void add(vector<int>x,string s){ if(x.size()==1)return; vector<int>a,b; for(int i=0;i<x.size()/2;i++)a.push_back(x[i]); for(int i=x.size()/2;i<x.size();i++)b.push_back(x[i]); for(auto i:a){ s[i]='1'; add_element(s); s[i]='0'; } for(auto i:b)s[i]='1'; add(a,s); for(auto i:b)s[i]='0'; for(auto i:a)s[i]='1'; add(b,s); } void check(vector<int>x,string s,int l,int r){ if(x.size()==1){ ans[x[0]]=l; return; } int m=(l+r)/2; vector<int>a,b; for(auto i:x){ s[i]='1'; if(check_element(s))a.push_back(i); else b.push_back(i); s[i]='0'; } for(auto i:b)s[i]='1'; check(a,s,l,m); for(auto i:b)s[i]='0'; for(auto i:a)s[i]='1'; check(b,s,m,r); } vector<int> restore_permutation(int n, int w, int r) { string s; for(int i=0;i<n;i++)s+='0'; vector<int>x; for(int i=0;i<n;i++)x.push_back(i); add(x,s); compile_set(); ans.resize(n); check(x,s,0,n); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void add(std::vector<int>, std::string)':
messy.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i<x.size()/2;i++)a.push_back(x[i]);
      |                 ~^~~~~~~~~~~
messy.cpp:10:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=x.size()/2;i<x.size();i++)b.push_back(x[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...