제출 #65300

#제출 시각아이디문제언어결과실행 시간메모리
65300mhndUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
4 ms512 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const int N = 3e5+50; const ll oo = 1e18; const ll mod = 1e9+7; vector<int> ans; void add(int n,int l,int r){ if(l+1 == r)return; int md = (l+r)/2; string s = ""; for(int i=0;i<n;i++)s += '1'; for(int i=l;i<r;i++)s[i] = '0'; for(int i=l;i<md;i++){ s[i] = '1'; add_element(s); s[i] = '0'; } add(n,l,md); add(n,md,r); } void ask(int n,int l,int r,string s){ if(l+1 == r){ for(int i=0;i<n;i++) if(s[i] == '0'){ ans[i] = l; break; } return; } string x=s,y=""; for(int i=0;i<n;i++)y+='1'; for(int i=0;i<n;i++){ if(s[i] == '0'){ s[i]='1'; if(check_element(s)){ x[i] = '1'; y[i] = '0'; } s[i]='0'; } } int md = (l+r)/2; ask(n,l,md,y); ask(n,md,r,x); } vector<int> restore_permutation(int n, int w, int r) { add(n,0,n); compile_set(); ans.resize(n); string a = ""; for(int i=0;i<n;i++)a += '0'; ask(n,0,n,a); 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...