Submission #76579

#TimeUsernameProblemLanguageResultExecution timeMemory
76579XylofoMechanical Doll (IOI18_doll)C++14
100 / 100
155 ms11100 KiB
#include <bits/stdc++.h> #include "doll.h" using namespace std; #define rep(i,a,b) for(int i = a; i<b; ++i) using vi = vector<int>; void create_circuit(int m, vi a) { a.push_back(0); int n = a.size(); int nn = (n+1)/2; vi x(nn),y(nn); auto add = [&](int e1, int e2) { y.push_back(-e1-1); x.push_back(-e2-1); }; int l = 0, r = nn; while(r-l != 1) { for(; l+1 < r; l+=2) add(l, l+1); if(l < r) add(l++, -1); r = x.size(); } rep(i,0,r) { if(x[i] == 0) x[i] = -r; if(y[i] == 0) y[i] = -r; } vi c(m+1, -r); int cnt = 0; int node = 0; vi state(x.size(), 0); int stCount = 0; while(cnt < n) { if(node < 0) { node = -node-1; state[node] = 1-state[node]; stCount += 2*state[node]-1; int& nxt = state[node] ? x[node] : y[node]; if(node < nn) { if(cnt < n-1 || stCount == 0) nxt = a[cnt++]; } node = nxt; } else node = c[node]; } // rep(i,0,m+1) cout << i << " " << c[i] << endl; // rep(i,0,r) cout << -(i+1) << " " << x[i] << " " << y[i] << endl; 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...