Submission #1182358

#TimeUsernameProblemLanguageResultExecution timeMemory
1182358NonozeUnscrambling a Messy Bug (IOI16_messy)C++20
0 / 100
2 ms584 KiB
#include "messy.h" #include <bits/stdc++.h> #define sz(x) (int)(x).size() using namespace std; int calc(string shouldbe, string s) { for (int i=0; i<sz(s); i++) if (shouldbe[i]=='0') { shouldbe[i]='1'; if (check_element(shouldbe)) return i; shouldbe[i]='0'; } return -1; } // 2 1 3 0 -> 3 1 0 2 vector<int> restore_permutation(int n, int w, int r) { vector<int> p(n, -1); vector<vector<int>> ans, ans2; string shouldbe(n, '0'), s(n, '0'); for (int val=1, idx=1; val<n; val*=2, idx++) { s[n-idx]='1'; add_element(s); for (int i=0; i<n; i++) { if ((i/val)%2 == 0) { s[i]='1'; add_element(s); s[i]='0'; } } } compile_set(); for (int val=1; val<n; val*=2) { s[n-sz(ans)-1]='1'; p[n-sz(ans)-1]=calc(shouldbe, s); shouldbe[p[n-sz(ans)-1]]='1'; ans.push_back({}), ans2.push_back({}); for (int i=0; i<n; i++) if (shouldbe[i]=='0') { shouldbe[i]='1'; if (check_element(shouldbe)) ans.back().push_back(i); else ans2.back().push_back(i); shouldbe[i]='0'; } else ans2.back().push_back(i); } for (int i=0; i<n-sz(ans); i++) { set<int> possible; for (int j=0; j<n; j++) possible.insert(j); for (int LOG=0; LOG<sz(ans); LOG++) { set<int> npossible; if ((i&(1<<LOG)) == 0) { for (auto &u: ans[LOG]) { if (possible.count(u)) { npossible.insert(u); } } } else { for (auto &u: ans2[LOG]) { if (possible.count(u)) { npossible.insert(u); } } } possible=npossible; } p[i]=*possible.begin(); } vector<int> np(n); for (int i=0; i<n; i++) np[p[i]]=i; return np; }

Compilation message (stderr)

messy.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
messy_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...