제출 #973471

#제출 시각아이디문제언어결과실행 시간메모리
973471sleepntsheepUnscrambling a Messy Bug (IOI16_messy)C11
100 / 100
4 ms2400 KiB
#include "messy_c.h" #define N 128 void solve_add(int n, int w, int r, int x, int y) { if (x == y) return; char ask[N+1]={0}; for(int i=0;i<n;++i)ask[i]='0' + (i<x||i>y); int m = x+(y-x)/2; for(int i=x;i<=m;++i) { ask[i]='1'; add_element(ask); ask[i]='0'; } solve_add(n, w, r, x, m); solve_add(n, w, r, m+1, y); } void solve_restore(int n, int w, int r, int x, int y, int *mapped, int *result) { if (x == y) { result[x] = mapped[0]; return; } char ask[N+1]={0}; for(int i=0;i<n;++i)ask[i]='1'; for(int i=x;i<=y;++i)ask[mapped[i-x]]='0'; int nmapped[N],no=0,mmapped[N],mo=0; int m=x+(y-x)/2; for(int i=x;i<=y;++i) { ask[mapped[i-x]]='1'; if(check_element(ask)) nmapped[no++]=mapped[i-x]; else mmapped[mo++]=mapped[i-x]; ask[mapped[i-x]]='0'; } solve_restore(n, w, r, x, m, nmapped, result); solve_restore(n, w, r, m+1, y, mmapped, result); } void restore_permutation(int n, int w, int r, int* result) { solve_add(n, w, r, 0, n-1); compile_set(); int mapped[N], iresult[N]; for (int i = 0; i < n; ++i) mapped[i] = i; solve_restore(n, w, r, 0, n-1, mapped, iresult); for (int i=0;i<n;++i)result[iresult[i]]=i; }
#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...