Submission #414470

#TimeUsernameProblemLanguageResultExecution timeMemory
414470sofapudenMechanical Doll (IOI18_doll)C++14
0 / 100
1 ms204 KiB
#include "doll.h" #include<bits/stdc++.h> using namespace std; vector<int> X, Y, NOW; int cn = 0, cnt = 0; int N, h; void fin(int x, int n, int par, bool ok, int val, vector<int> &A){ if(x < 0)return; if(x < cnt-1){ NOW[x]^=1; if(NOW[x]){ if(Y[x] == -1)fin(0,N,0,0,1<<(h-1),A); else if(Y[x] != 5)fin((-Y[x])-1,min(n,val),x,1,val>>1,A); else{ X.push_back(5); Y.push_back(5); NOW.push_back(0); fin(cnt++, min(n,val),x,1,val>>1,A); } } else { if(X[x] == -1)fin(0,N,0,0,1<<(h-1),A); else if(X[x] != 5)fin((-X[x])-1,max(n-val,0),x,0,val>>1,A); else fin(cnt++, max(n-val,0),x,0,val>>1,A); } return; } if(!n){ cout << "HEY\n" << par << "\n"; if(ok)Y[par] = -1; else X[par] = -1; cnt--; X.pop_back(); Y.pop_back(); NOW.pop_back(); fin(0,N,0,0,1<<(h-1),A); return; } if(!val){ if(ok)Y[par] = A[cn++]; else X[par] = A[cn++]; cnt--; X.pop_back(); Y.pop_back(); NOW.pop_back(); if(cn == N)return; fin(0,N,0,0,1<<(h-1),A); return; } if(x != 0){ if(ok)Y[par] = (-x)-1; else X[par] = (-x)-1; } X.push_back(5); Y.push_back(5); NOW.push_back(0); fin(cnt++,max(n-val,0),x,0,val>>1,A); } void create_circuit(int m, vector<int> A) { A.push_back(0); N = A.size(); h = (int)(ceil(log2(N))); vector<int> C(m + 1,-1); X.push_back(5); Y.push_back(5); NOW.push_back(0); fin(0,N,0,0,1<<(h-1),A); cout << "CN: " << cn << "\n"; cout << "CNT: " << cnt << "\n"; for(int i : X)cout << i << " "; cout << "\n"; for(int i : Y)cout << i << " "; cout << "\n"; answer(C, X, Y); }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...