Submission #1021143

#TimeUsernameProblemLanguageResultExecution timeMemory
1021143ZicrusMechanical Doll (IOI18_doll)C++17
18 / 100
67 ms13632 KiB
#include <bits/stdc++.h> #include "doll.h" using namespace std; typedef long long ll; vector<int> C, X, Y; int connect(int a, int bSize, int b, int orig = 0, int mask = 0, int bit = 0) { if (!bit && orig) return b; X.push_back(0); Y.push_back(0); int id = X.size() - 1; bool first = false; if (!orig) { first = true; orig = -X.size(); mask = bSize - 1; if (mask == 0) { X.pop_back(); Y.pop_back(); return b; } bit = 1 << (int)log2(mask); } if (mask & bit) { X[id] = connect(a, bSize - (1 << ((int)log2(bSize) - 1)), b, orig, mask, bit >> 1); Y[id] = connect(a, 1 << ((int)log2(bSize) - 1), b, orig, ~0, bit >> 1); } else { X[id] = orig; Y[id] = connect(a, 1 << ((int)log2(bSize) - 1), b, orig, mask, bit >> 1); } if (first) { Y[X.size() - 1] = 0; } return -id - 1; } void create_circuit(int M, vector<int> A) { A.push_back(0); C = vector<int>(M + 1); X = vector<int>(); Y = vector<int>(); vector<vector<int>> adj(M + 1); int prev = 0; for(auto &e : A) { adj[prev].push_back(e); prev = e; } for (int i = 0; i < adj.size(); i++) { C[i] = connect(i, adj[i].size(), adj[i][0]); } answer(C, X, Y); return; }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:54:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int i = 0; i < adj.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...