Submission #75292

#TimeUsernameProblemLanguageResultExecution timeMemory
75292KieranHorganMechanical Doll (IOI18_doll)C++17
37 / 100
167 ms12920 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; vector<int> A, X, Y, C; int dep[200]; int nextTrigger = -1; int solve(vector<int> a, int d) { if(a.size() == 1) return a[0]; int trigger = nextTrigger--; vector<int> b; dep[d]++; for(int i = 0; i < a.size(); i+=2) b.push_back(a[i]); int l = solve(b, d+1); b.clear(); for(int i = 1; i < a.size(); i+=2) b.push_back(a[i]); int r = solve(b, d+1); b.clear(); if(-(trigger+1) >= X.size()) X.resize(-(trigger)), Y.resize(-(trigger)); X[-(trigger+1)] = l; Y[-(trigger+1)] = r; return trigger; } void create_circuit(int M, vector<int> A_) { A = A_; int N = A.size(); while(__builtin_popcount(A.size()+1) != 1) { A.push_back(-1); } A.push_back(0); C.assign(M+1, -1); solve(A, 1); // cerr << nextTrigger << endl; // for(int i = 1; dep[i]; i++) // cerr << i << ": " << dep[i] << endl; // // cerr << N << " " << X.size() << endl; answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'int solve(std::vector<int>, int)':
doll.cpp:13:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |   for(int i = 0; i < a.size(); i+=2)
      |                  ~~^~~~~~~~~~
doll.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   for(int i = 1; i < a.size(); i+=2)
      |                  ~~^~~~~~~~~~
doll.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   if(-(trigger+1) >= X.size())
      |      ~~~~~~~~~~~~~^~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:31:7: warning: unused variable 'N' [-Wunused-variable]
   31 |   int N = A.size();
      |       ^
#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...