Submission #958392

#TimeUsernameProblemLanguageResultExecution timeMemory
958392AkibAzmainMechanical Doll (IOI18_doll)C++17
6 / 100
62 ms12356 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; using ll = long long; void create_circuit(int m, std::vector<int> a) { int p = 0; a.push_back (0); vector < vector < int > > adj (m + 1); for (auto &x : a) adj[p].push_back (x), p = x; vector < int > c (m + 1), x, y; x.reserve (a.size () * 2); y.reserve (a.size () * 2); for (int i = 0; i <= m; ++i) { if (adj[i].empty ()) continue; if (adj[i].size () == 1) { c[i] = adj[i][0]; continue; } int vt = 1, vtt = 0; while (vt < adj[i].size ()) vt *= 2, ++vtt; vector < int > v (vt, -(x.size () + 1)); for (int j = 0; j < adj[i].size (); ++j) { int k = j, q = 0; for (int p = 0; p < vtt; ++p) q = q * 2 + k % 2, k /= 2; v[q] = adj[i][j]; } auto f = [&] (auto &self, int &p, int l, int r) -> void { if (l + 1 == r) p = v[l]; else { int m = (l + r) / 2; x.push_back (0), y.push_back (0); p = -x.size (); self (self, x.back (), l, m); self (self, y.back (), m, r); } }; f (f, c[i], 0, vt); } answer (c, x, y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:23:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |       while (vt < adj[i].size ()) vt *= 2, ++vtt;
      |              ~~~^~~~~~~~~~~~~~~~
doll.cpp:25:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |       for (int j = 0; j < adj[i].size (); ++j)
      |                       ~~^~~~~~~~~~~~~~~~
#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...