Submission #206477

#TimeUsernameProblemLanguageResultExecution timeMemory
206477spdskatrMechanical Doll (IOI18_doll)C++14
84 / 100
123 ms14828 KiB
#include "doll.h" #include <cassert> #include <vector> #include <cstdio> #include <cstdlib> #include <utility> #include <algorithm> #define fi first #define se second using namespace std; typedef pair<int, int> pii; int target[1<<18], bitcnt, N, startpos, cnt; vector<int> a, X, Y; vector<pii> perm; vector<int> seq[19]; // Returns ID to new node created int create(int l, int r) { if (r < startpos) { return -1; } if (l == r) { return target[l]; } int id = cnt++; X.push_back(0); Y.push_back(0); int mid = (l + r) / 2; int xv = create(l, mid); int yv = create(mid+1, r); X[id] = xv, Y[id] = yv; return -(id+1); } void create_circuit(int M, std::vector<int> A) { N = A.size() + 1; // N = N+1 :thonk: a = vector<int>(A); a.push_back(0); std::vector<int> C(M + 1); C[0] = -1; for (int i = 1; i <= M; ++i) { C[i] = -1; } bitcnt = 32 - __builtin_clz(N); seq[0].push_back(0); for (int i = 1; i <= bitcnt; i++) { for (int x : seq[i-1]) { seq[i].push_back(x); seq[i].push_back(x + (1 << (i-1))); } } startpos = (1 << bitcnt) - N; for (int i = startpos; i < seq[bitcnt].size(); i++) { perm.push_back({ seq[bitcnt][i], i }); } assert(perm.size() == N); sort(perm.begin(), perm.end()); for (int i = 0; i < N; i++) { target[perm[i].se] = a[i]; } create(0, (1 << bitcnt) - 1); answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:55:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for (int i = startpos; i < seq[bitcnt].size(); i++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from doll.cpp:2:
doll.cpp:58:21: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |  assert(perm.size() == N);
      |         ~~~~~~~~~~~~^~~~
#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...