Submission #780628

#TimeUsernameProblemLanguageResultExecution timeMemory
780628sofija6Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms468 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; void Add(int l,int r,int n) { if (l==r) return; string s=""; for (int i=0;i<n;i++) s+='0'; for (int i=0;i<l;i++) s[i]='1'; for (int i=r+1;i<n;i++) s[i]='1'; for (int i=l;i<=(l+r)/2;i++) { s[i]='1'; add_element(s); s[i]='0'; } Add(l,(l+r)/2,n); Add((l+r)/2+1,r,n); } vector<int> ans; void Solve(int l,int r,int n,set<int> pos) { if (l==r) { ans[*pos.begin()]=l; return; } string s; for (int i=0;i<n;i++) { if (!pos.count(i)) s+='1'; else s+='0'; } set<int> pos1,pos2; for (auto i : pos) { s[i]='1'; if (check_element(s)) { pos1.insert(i); if (pos1.size()==(l+r+1)/2) break; } s[i]='0'; } for (auto i : pos) { if (!pos1.count(i)) pos2.insert(i); } Solve(l,(l+r)/2,n,pos1); Solve((l+r)/2+1,r,n,pos2); } std::vector<int> restore_permutation(int n, int w, int r) { Add(0,n-1,n); for (int i=0;i<n;i++) ans.push_back(0); set<int> s; for (int i=0;i<n;i++) s.insert(i); compile_set(); Solve(0,n-1,n,s); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void Solve(int, int, int, std::set<int>)':
messy.cpp:47:28: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |             if (pos1.size()==(l+r+1)/2)
      |                 ~~~~~~~~~~~^~~~~~~~~~~
#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...