Submission #198339

#TimeUsernameProblemLanguageResultExecution timeMemory
198339stefdascaUnscrambling a Messy Bug (IOI16_messy)C++14
0 / 100
5 ms2424 KiB
#include<bits/stdc++.h> #include<messy.h> using namespace std; int sz; /* int perm[202]; set<string> test, tru; // to be removed when submitting void add_element(string s) { test.insert(s); } bool check_element(string s) { if(tru.find(s) != tru.end()) return 1; return 0; } void compile_set() { string ans; for(int i = 0; i < sz; ++i) ans += '0'; for(set<string> ::iterator it = test.begin(); it != test.end(); ++it) { string ss = *it; for(int i = 0; i < sz; ++i) ans[i] = '0'; for(int i = 0; i < sz; ++i) ans[perm[i]] = ss[i]; tru.insert(ans); } } */ int poz[202]; vector<int> pospoz[202][202]; void build(int st, int dr) { if(st == dr) return; string s; for(int i = 0; i < sz; ++i) s += '1'; int mid = (st + dr) / 2; for(int i = st; i <= dr; ++i) s[i] = '0'; for(int i = st; i <= mid; ++i) { s[i] = '1'; // cout << st << " " << dr << " " << s << '\n'; if(s.size() != sz) { while(1); add_element(s); } s[i] = '0'; } build(st, mid); build(mid+1, dr); } void restore(int st, int dr) { if(st == dr) { poz[st] = pospoz[st][st][0]; return; } string s; for(int i = 0; i < sz; ++i) s += '0'; bool oki[150] = {0}; for(int i = 0; i < pospoz[st][dr].size(); ++i) oki[pospoz[st][dr][i]] = 1; for(int i = 0; i < sz; ++i) if(!oki[i]) s[i] = '1'; int mid = (st + dr) / 2; for(int i = 0; i < pospoz[st][dr].size(); ++i) { int pp = pospoz[st][dr][i]; s[pp] = '1'; if(s.size() != sz) while(1); bool xxx = check_element(s); if(xxx) pospoz[st][mid].push_back(pp); else pospoz[mid+1][dr].push_back(pp); s[pp] = '0'; } restore(st, mid); restore(mid+1, dr); } vector<int> restore_permutation(int n, int w, int r) { sz = n; build(0, n-1); compile_set(); for(int i = 0; i < n; ++i) pospoz[0][n-1].push_back(i); restore(0, n-1); vector<int> ans; for(int i = 0; i < n; ++i) ans.push_back(poz[i]); return ans; } /* // to be removed when submitting int main() { int n, w, r; cin >> n >> w >> r; int seed; cin >> seed; for(int i = 0; i < n; ++i) perm[i] = i; for(int i = 0; i < seed; ++i) random_shuffle(perm, perm + n); for(int i = 0; i < n; ++i) cout << perm[i] << " "; cout << '\n'; vector<int> ans = restore_permutation(n, w, r); for(int i = 0; i < n; ++i) cout << ans[i] << " "; return 0; } */

Compilation message (stderr)

messy.cpp: In function 'void build(int, int)':
messy.cpp:54:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(s.size() != sz)
            ~~~~~~~~~^~~~~
messy.cpp: In function 'void restore(int, int)':
messy.cpp:75:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < pospoz[st][dr].size(); ++i)
                    ~~^~~~~~~~~~~~~~~~~~~~~~~
messy.cpp:81:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < pospoz[st][dr].size(); ++i)
                    ~~^~~~~~~~~~~~~~~~~~~~~~~
messy.cpp:85:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(s.size() != sz)
            ~~~~~~~~~^~~~~
#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...