Submission #1074119

#TimeUsernameProblemLanguageResultExecution timeMemory
1074119TB_Mechanical Doll (IOI18_doll)C++17
53 / 100
88 ms18324 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define fo(i, n) for(ll i = 0; i<(n); i++) #define pb push_back #define F first #define S second #define deb(x) cout << #x << " = " << (x) << endl #define deb2(x, y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl typedef vector<ll> vl; typedef vector<vl> vvl; // void answer(std::vector<int> C, std::vector<int> X, std::vector<int> Y){ // } void answer(std::vector<int> C, std::vector<int> X, std::vector<int> Y); void create_circuit(int M, std::vector<int> A){ vvl adj(M+1); ll n = A.size(); adj[0].pb(A[0]); fo(i, n){ if(i<n-1) adj[A[i]].pb(A[i+1]); else adj[A[i]].pb(0); } ll cou = 0; vector<int> c, x, y; fo(i, M+1){ cou = x.size(); ll co = 0; if(adj[i].size() == 0){ c.pb(i); continue; } else if(adj[i].size() == 1){ c.pb(adj[i][0]); continue; } c.pb(-cou-1); ll am = adj[i].size(); ll ext = 1; while(ext<am) ext*=2ll; ll am2 = ext-am; vl order(ext*2); vl state(ext, 0); fo(j, ext){ ll current = 1; while(current<ext){ ll sta = state[current]; state[current] = !state[current]; current*=2; if(sta)current++; } if(j<am2) order[current] = (-cou-1); else order[current] = (adj[i][co++]); // deb2(current, order[current]); } co= 0; fo(i, ext){ if(!i) continue; if(i*2<ext){ x.pb(-cou-i*2); y.pb(-cou-i*2-1); }else{ x.pb(order[i*2]); y.pb(order[i*2+1]); } } } // fo(i, c.size()){ // deb(c[i]); // } // fo(i, x.size()){ // deb2(x[i], y[i]); // } answer(c, x, y); } // int main(){ // vector<int> st = {1, 2, 1, 2, 1, 2}; // create_circuit(2, st); // return 0; // }
#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...