Submission #1247624

#TimeUsernameProblemLanguageResultExecution timeMemory
1247624julia_08Unscrambling a Messy Bug (IOI16_messy)C++20
38 / 100
2 ms328 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 128; int to[MAXN], marc[MAXN]; int n; string str(int x){ string s; for(int i=0; i<n; i++){ if(x & (1 << i)){ s.push_back('1'); } else s.push_back('0'); } reverse(s.begin(), s.end()); return s; } vector<int> restore_permutation(int n_, int w, int r){ n = n_; for(int i=0; i<n; i++) add_element(str((1 << (i + 1)) - 1)); compile_set(); vector<int> ans(n); int cur = 0; vector<int> v; for(int i=0; i<n; i++) v.push_back(i); for(int i=0; i<n; i++){ bool ok = false; for(int k=0; k<v.size(); k++){ int j = v[k]; if(j != i) continue; if(check_element(str(cur ^ (1 << j)))){ cur ^= (1 << j); to[n - 1 - i] = n - 1 - j; marc[j] = 1; swap(v[k], v.back()); v.pop_back(); ok = true; break; } } if(ok) continue; shuffle(v.begin(), v.end(), rng); for(int k=0; k<v.size(); k++){ int j = v[k]; if(check_element(str(cur ^ (1 << j)))){ cur ^= (1 << j); to[n - 1 - i] = n - 1 - j; marc[j] = 1; swap(v[k], v.back()); v.pop_back(); break; } } } for(int i=0; i<n; i++) ans[to[i]] = i; return ans; }

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...