Submission #788548

#TimeUsernameProblemLanguageResultExecution timeMemory
788548AndreyMechanical Doll (IOI18_doll)C++14
85.55 / 100
89 ms19568 KiB
#include "doll.h" #include<bits/stdc++.h> using namespace std; vector<int> haha[200001]; vector<int> idk(500001); int br = 1,yeah; vector<int> x(0); vector<int> y(0); void dude(int a, int d) { x.push_back(0); y.push_back(0); int ind = br-1; br++; if(d < 0) { if(a == 2) { x[ind] = INT_MAX; y[ind] = INT_MAX; } else { x[ind] = yeah; y[ind] = INT_MAX; } return; } int z = (1 << (d+1)); if(a <= z) { x[ind] = yeah; y[ind] = -br; dude(a,d-1); } else { x[ind] = -br; dude(a-z,d-1); y[ind] = -br; dude(z,d-1); } } void create_circuit(int m, vector<int> bruh) { vector<int> c(m+1); c[0] = bruh[0]; int n = bruh.size(); bruh.push_back(0); int a,z = 0,b,p,d = 0,e = 1; for(int i = 0; i < n; i++) { haha[bruh[i]].push_back(bruh[i+1]); } for(int i = 0; i < 200001; i++) { if(haha[i].empty()) { continue; } if(haha[i].size() == 1) { c[i] = haha[i][0]; } else { c[i] = -br; yeah = -br; d = -1; e = 1; while(e*2 < haha[i].size()) { e*=2; d++; } dude(haha[i].size(),d); p = 0; for(int j = 0; j < haha[i].size(); j++) { d = -c[i]; if((++idk[d-1])%2) { e = x[d-1]; } else { e = y[d-1]; } while(e != INT_MAX) { d = -e; if((++idk[d-1])%2) { e = x[d-1]; } else { e = y[d-1]; } } if(idk[d-1]%2 == 1) { x[d-1] = haha[i][j]; } else { y[d-1] = haha[i][j]; } } } } answer(c,x,y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:62:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             while(e*2 < haha[i].size()) {
      |                   ~~~~^~~~~~~~~~~~~~~~
doll.cpp:68:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |             for(int j = 0; j < haha[i].size(); j++) {
      |                            ~~^~~~~~~~~~~~~~~~
doll.cpp:46:9: warning: unused variable 'a' [-Wunused-variable]
   46 |     int a,z = 0,b,p,d = 0,e = 1;
      |         ^
doll.cpp:46:11: warning: unused variable 'z' [-Wunused-variable]
   46 |     int a,z = 0,b,p,d = 0,e = 1;
      |           ^
doll.cpp:46:17: warning: unused variable 'b' [-Wunused-variable]
   46 |     int a,z = 0,b,p,d = 0,e = 1;
      |                 ^
doll.cpp:46:19: warning: variable 'p' set but not used [-Wunused-but-set-variable]
   46 |     int a,z = 0,b,p,d = 0,e = 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...