제출 #40518

#제출 시각아이디문제언어결과실행 시간메모리
40518PajarajaUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
7 ms560 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; int pe[130],pi[130]; std::vector<int> restore_permutation(int n, int w, int r) { string sn; for(int i=0;i<n;i++) sn+='0'; int logn=0; while((1<<logn)!=n) logn++; for(int i=logn-1;i>=0;i--) { for(int j=0;j<n;j++) if(((1<<i)|j)==j) { string s=sn; for(int x=0;x<n;x++) { if(x==j) { s[x]++; continue; } for(int k=i+1;k<logn;k++) if(((1<<k)&x)!=((1<<k)&j)) { s[x]++; break; } } add_element(s); } } compile_set(); for(int i=logn-1;i>=0;i--) { for(int j=0;j<n;j++) { string s=sn; for(int x=0;x<n;x++) { if(x==j) { s[x]++; continue; } for(int k=i+1;k<logn;k++) if(((1<<k)&pi[x])!=((1<<k)&pi[j])) { s[x]++; break; } } if(check_element(s)) pi[j]+=(1<<i); } } vector<int> sol; for(int i=0;i<n;i++) sol.push_back(pi[i]); return sol; }
#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...