Submission #75733

#TimeUsernameProblemLanguageResultExecution timeMemory
75733KieranHorganMechanical Doll (IOI18_doll)C++17
0 / 100
4 ms4940 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; vector<int> A, X, Y, C; int dep[200]; int nextSwitch = -1; vector<int> AdjList[200005]; int recurseThroughTree(vector<int> b) { if(b.size() == 1) return b[0]; int curSwitch = nextSwitch--; vector<int> a; for(int i = 0; i < b.size(); i+=2) a.push_back(b[i]); int l = a.back() == -1 ? -1 : recurseThroughTree(a); a.clear(); for(int i = 1; i < b.size(); i+=2) a.push_back(b[i]); int r = a.back() == -1 ? -1 : recurseThroughTree(a); if(X.size() <= abs(curSwitch)-1) X.resize(abs(curSwitch)), Y.resize(abs(curSwitch)); X[abs(curSwitch)-1] = l; Y[abs(curSwitch)-1] = r; return curSwitch; } int rev(int x, int n) { n = __builtin_ctz(n); int res = 0; for(int i = 0; i < n; i++) if(x & (1<<i)) res |= 1<<(n-1-i); return res; } void create_circuit(int M, vector<int> A_) { int N = A_.size(); A = A_; A.push_back(0); C.assign(M+1, -1); int dummies = 0; while(__builtin_popcount(A.size()+dummies) != 1) dummies++; vector<int> b; int i, j; for(i = 0, j = 0; j < A.size() + dummies; j++) { if(i >= A.size() || rev(j, A.size()+dummies) < dummies) b.push_back(-1); else b.push_back(A[i++]); } recurseThroughTree(b); double score; int S = X.size(); // cerr << S << " " << N+log2(N) << endl; if(S <= N + log2(N)) score = 1; else if(S <= 2*N) score = 0.5 + 0.4*((2*N - S)/(N-log2(N)))*((2*N - S)/(N-log2(N))); else score = 0; score *= 100; cout << "Score: " << setprecision(7) << fixed << score << "\t" ; answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'int recurseThroughTree(std::vector<int>)':
doll.cpp:15:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int i = 0; i < b.size(); i+=2)
      |                  ~~^~~~~~~~~~
doll.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i = 1; i < b.size(); i+=2)
      |                  ~~^~~~~~~~~~
doll.cpp:24:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   if(X.size() <= abs(curSwitch)-1) X.resize(abs(curSwitch)), Y.resize(abs(curSwitch));
      |      ~~~~~~~~~^~~~~~~~~~~~~~~~~~~
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(i = 0, j = 0; j < A.size() + dummies; j++) {
      |                     ~~^~~~~~~~~~~~~~~~~~~~
doll.cpp:53:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     if(i >= A.size() || rev(j, A.size()+dummies) < dummies) b.push_back(-1);
      |        ~~^~~~~~~~~~~
#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...