Submission #1069323

#TimeUsernameProblemLanguageResultExecution timeMemory
1069323andrei_iorgulescuMechanical Doll (IOI18_doll)C++14
100 / 100
125 ms20016 KiB
#include <bits/stdc++.h> #include "doll.h" #warning That's not FB, that's my FB using namespace std; int n,m; vector<int> a; vector<vector<int>> pos; vector<int> unde; int cur = 1; vector<int> c, x, y; int ngl, kgl, pgl; void build(int nume, int l, int r) { int mij = (l + r) / 2; if (mij <= pgl) x[-nume - 1] = -1; else { if (l != mij) { x[-nume - 1] = -cur; cur++; x.push_back(0); y.push_back(0); build(x[-nume - 1], l, mij); } else { //int pz = pos[ngl][unde[ngl]] + 1; //unde[ngl]++; x[-nume - 1] = 3 * n; } } if (mij + 1 != r) { y[-nume - 1] = -cur; cur++; x.push_back(0); y.push_back(0); build(y[-nume - 1], mij + 1, r); } else { //int pz = pos[ngl][unde[ngl]] + 1; //unde[ngl]++; y[-nume - 1] = 3 * n; } } void build_sgt(int nod) { cur = 2; kgl = __lg(n); if ((1 << kgl) < n) kgl++; pgl = (1 << kgl) - (int)n; build(nod, 1, (1 << kgl)); } int cr = 0; vector<int> how; void gogo(int nod) { //cout << nod << endl; if (nod == 0) return; if (nod >= 1) { cr++; gogo(c[nod]); return; } //cout << x[-nod - 1] << ' ' << y[-nod - 1] << ' ' << how[-nod - 1] << endl; if (how[-nod - 1] == 0) { how[-nod - 1] = 1; if (x[-nod - 1] > 2 * n) { x[-nod - 1] = a[cr]; //cr++; } gogo(x[-nod - 1]); } else { how[-nod - 1] = 0; if (y[-nod - 1] > 2 * n) { y[-nod - 1] = a[cr]; //cr++; } gogo(y[-nod - 1]); } } void create_circuit(int M, vector<int> A) { A.push_back(0); n = A.size(); a = A; m = M; pos.resize(m + 1); unde.resize(m + 1); for (int i = 0; i < a.size(); i++) pos[a[i]].push_back(i); a.push_back(0); c.resize(m + 1); for (int i = 0; i <= m; i++) c[i] = -1; x.push_back(0); y.push_back(0); how.resize(2 * n); build_sgt(-1); gogo(-1); /*for (auto it : c) cout << it << ' '; cout << endl; for (auto it : x) cout << it << ' '; cout << endl; for (auto it : y) cout << it << ' '; cout << endl;*/ answer(c, x, y); }

Compilation message (stderr)

doll.cpp:3:2: warning: #warning That's not FB, that's my FB [-Wcpp]
    3 | #warning That's not FB, that's my FB
      |  ^~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:110:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  110 |     for (int i = 0; i < a.size(); 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...
#Verdict Execution timeMemoryGrader output
Fetching results...