제출 #434402

#제출 시각아이디문제언어결과실행 시간메모리
434402OttoTheDinoUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms492 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; #define rep(i,s,e) for (int i = s; i <= e; ++i) #define rrep(i,s,e) for (int i = s; i >= e; --i) #define pb push_back #define pf push_front #define fi first #define se second typedef long long ll; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<double> vd; typedef vector<string> vs; typedef vector<char> vc; typedef vector<ll> vll; const int mxn = 1000; vi ans(mxn); void divide (int n, int l, int r) { int rl = (l+r+1)/2, lr = (l+r)/2; rep (i,rl,(rl+r)/2) { string s(n,'0'); rep (j,l,lr) s[j-1] = '1'; s[i-1] = '1'; add_element(s); } rep (i,l,(l+lr)/2) { string s(n,'0'); s[i-1] = '1'; rep (j,rl,r) s[j-1] = '1'; add_element(s); } if (r-l+1==4) return; divide (n, l, lr), divide (n, rl, r); } void get_dividance (int n, int l, int r, string left, string all) { string right(n,'0'), rleft(n,'0'),lleft(n,'0'); rep (i,1,n) { if (all[i-1]!='1') continue; if (left[i-1]!='1') { left[i-1] = right[i-1] = '1'; if (check_element(left)) rleft[i-1] = '1'; left[i-1] = '0'; } } rep (i,1,n) { if (all[i-1]!='1') continue; if (right[i-1]!='1') { right[i-1] = '1'; if (check_element(right)) lleft[i-1] = '1'; right[i-1] = '0'; } } if (r-l+1==4) { int a[4]; rep (i,0,n-1) { if (left[i]=='1') { if (lleft[i]=='1') a[0] = i; else a[1] = i; } if (right[i]=='1') { if (rleft[i]=='1') a[2] = i; else a[3] = i; } } rep (i,0,3) { ans[a[i]] = l+i-1; } return; } get_dividance(n,l,(l+r)/2,lleft,left), get_dividance(n,(l+r+1)/2,r,rleft,right); } vi restore_permutation(int n, int w, int r) { rep (i,1,n/2) { string s(n,'0'); s[i-1] = '1'; add_element(s); } divide(n, 1, n); compile_set(); string left(n,'0'); rep (i,1,n) { string s(n,'0'); s[i-1] = '1'; if (check_element(s)) left[i-1]='1'; } string all(n,'1'); get_dividance(n,1,n,left,all); ans.resize(n); return ans; }
#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...