Submission #958394

#TimeUsernameProblemLanguageResultExecution timeMemory
958394AkibAzmainMechanical Doll (IOI18_doll)C++17
15 / 100
74 ms13680 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, -((int) x.size () + 1)); for (int j = 0; j < adj[i].size (); ++j) { int k = j, q = 0; if (adj[i][j] == 0) k = vt - 1; for (int p = 0; p < vtt; ++p) q = q * 2 + k % 2, k /= 2; v[q] = adj[i][j]; } auto f = [&] (auto &self, int l, int r) -> int { if (l + 1 == r) return v[l]; int m = (l + r) / 2; x.push_back (0), y.push_back (0); int i = x.size () - 1; x[i] = self (self, l, m); y[i] = self (self, m, r); return -(i + 1); }; c[i] = f (f, 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...