Submission #312352

#TimeUsernameProblemLanguageResultExecution timeMemory
312352kylych03Mechanical Doll (IOI18_doll)C++14
6 / 100
631 ms17508 KiB
#include "doll.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; int vis[200002]; vector <int> x,y; vector <int> vec[200002]; int cnt = 1; void rec(vector <int > v, int k){ vector <int> v1, v2; if(v.size()==0) return ; if(v.size()==2){ x.push_back(v[0]); y.push_back(v[1]); cnt++; return ; } int i = 0; for(; i < v.size()/2; i++){ if(v[i] < 0) v1.push_back(v[i]); else{ break; } } cout << i<<endl; for( ; i < v.size(); i++){ if(v1.size() > v2.size()) v2.push_back(v[i]); else v1.push_back(v[i]); cout << v[i]<<endl; } int p = cnt; cnt++; y.push_back(-cnt); if(v1[v1.size()-1] >=0){ x.push_back(-cnt); rec(v1,k); } else x.push_back(k); y[p-1]=-cnt; rec(v2,k); } void create_circuit(int M, std::vector<int> A) { vector<int> C(M + 1); vector <int> X, Y; for(int i = 0; i<M+1; i++){ C[i]=0; } C[0]=A[0]; A.push_back(0); int N = A.size(); for(int i = 0 ; i < N; i++){ vec[A[i]].push_back(A[i+1]); } for(int i = 1 ; i <=M ;i++){ if(vec[i].size()>1){ C[i] = -cnt; int pw = 1; while(pw < vec[i].size()){ pw = pw * 2; } int len = vec[i].size(); while(len < pw){ len++; vec[i].insert(vec[i].begin(), C[i]); } rec( vec[i],C[i]); } if(vec[i].size()==1) C[i]=vec[i][0]; } /* for(int i = 0; i <C.size(); i++) cout << C[i]<<" "; cout << endl; for(int i = 0; i <x.size(); i++) cout << x[i]<<" "<<y[i]<<endl; cout << endl; */ answer(C, x, y); }

Compilation message (stderr)

doll.cpp: In function 'void rec(std::vector<int>, int)':
doll.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(; i < v.size()/2; i++){
      |           ~~^~~~~~~~~~~~
doll.cpp:29:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for( ; i < v.size(); i++){
      |            ~~^~~~~~~~~~
doll.cpp:32:9: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   32 |         else
      |         ^~~~
doll.cpp:34:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   34 |             cout << v[i]<<endl;
      |             ^~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:68:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |             while(pw < vec[i].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...