Submission #83467

#TimeUsernameProblemLanguageResultExecution timeMemory
83467aquablitz11Mechanical Doll (IOI18_doll)C++14
100 / 100
143 ms10460 KiB
#include <bits/stdc++.h> #include "doll.h" using namespace std; vector<int> X, Y; int get(int l, int r) { X.push_back(l); Y.push_back(r); return -X.size(); } int solve(vector<int> &A) { vector<int> L, R; bool diff = false; for (int i = 0; i < A.size(); ++i) { if (A[i] != A[0]) diff = true; if (i%2==0) L.push_back(A[i]); else R.push_back(A[i]); } if (!diff) return A[0]; A.clear(); int l = solve(L); int r = solve(R); return get(l, r); } int rev(int n, int i) { int val = 0; while (n--) { val <<= 1; val |= i&1; i >>= 1; } return val; } void create_circuit(int m, vector<int> A) { A.push_back(0); int n = A.size(); int k = 0; while ((1<<k) < n) ++k; vector<int> B(1<<k, 0); for (int i = 0; i < n; ++i) { int r = rev(k, (1<<k)-i-1); B[r] = 1; } int c = 0; for (int i = 0; i < (1<<k); ++i) { if (B[i]) B[i] = A[c++]; else B[i] = m+1; } int u = solve(B); for (int i = 0; i < X.size(); ++i) { if (X[i] == m+1) X[i] = u; if (Y[i] == m+1) Y[i] = u; } vector<int> C(m+1, u); answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'int solve(std::vector<int>&)':
doll.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i = 0; i < A.size(); ++i) {
      |                     ~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:52:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for (int i = 0; i < X.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...