Submission #414348

#TimeUsernameProblemLanguageResultExecution timeMemory
414348DBPhoenixMechanical Doll (IOI18_doll)C++17
6 / 100
131 ms19872 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; struct Tree { int pointer = 1; vector<int> nodes = {0}; }; int switches = 0; Tree tree[200001]; void insert(int i, int value) { if (tree[i].pointer == 1) { tree[i].nodes.push_back(value); tree[i].pointer++; return; } if (tree[i].nodes[tree[i].pointer / 2] > -1) { tree[i].nodes.push_back(tree[i].nodes[tree[i].pointer / 2]); tree[i].nodes[tree[i].pointer / 2] = -(++switches); tree[i].pointer++; } tree[i].nodes.push_back(value); tree[i].pointer++; } void create_circuit(int M, std::vector<int> A) { int N = A.size(); int prev = 0; for (int a : A) { insert(prev, a); prev = a; } insert(prev, 0); vector<int> C(M + 1); for (int i = 0; i <= M; ++i) { if (tree[i].nodes.size() < 2) C[i] = 1; else C[i] = tree[i].nodes[1]; } vector<int> X(switches); vector<int> Y(switches); for (int i = 0; i <= M; i++) { for (int j = 1; true; j++) if (tree[i].nodes[j] > -1) break; else { X[-tree[i].nodes[j] - 1] = tree[i].nodes[j * 2]; Y[-tree[i].nodes[j] - 1] = tree[i].nodes[j * 2 + 1]; } } answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:33:7: warning: unused variable 'N' [-Wunused-variable]
   33 |   int N = A.size();
      |       ^
#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...