Submission #94983

#TimeUsernameProblemLanguageResultExecution timeMemory
94983someone_aaMechanical Doll (IOI18_doll)C++17
16 / 100
123 ms11748 KiB
#include <bits/stdc++.h> #include "doll.h" #define pb push_back #define mp make_pair using namespace std; const int maxm = 100100; vector<int> after[maxm]; void create_circuit(int M, std::vector<int> A) { int N = A.size(); std::vector<int> C(M + 1, 0); C[0] = A[0]; for(int i=1;i<A.size();i++) { after[A[i-1]].pb(A[i]); } after[A.back()].pb(0); vector<int> X, Y; int br = 1; for(int i=1;i<=M;i++) { //cout<<i<<": "<<after[i].size()<<"\n"; if(after[i].size() == 0) continue; else if(after[i].size() == 1) { C[i] = after[i][0]; } else if(after[i].size() == 2){ C[i] = -br; X.pb(after[i][0]); Y.pb(after[i][1]); br++; } else if(after[i].size() == 3) { C[i] = -br; int lbr = br + 1; int rbr = br + 2; X.pb(-lbr); Y.pb(-rbr); //cout<<i<<": "<<(-lbr)<<" and "<<(-rbr)<<"\n"; X.pb(after[i][0]); Y.pb(-br); //cout<<after[i][0]<<" "<<i<<"\n"; X.pb(after[i][1]); Y.pb(after[i][2]); br += 3; } else { C[i] = -br; int lbr = br + 1; int rbr = br + 2; X.pb(-lbr); Y.pb(-rbr); X.pb(after[i][0]); Y.pb(after[i][2]); X.pb(after[i][1]); Y.pb(after[i][3]); br += 3; } } /*for (int k = 0; k < N; ++k) { X[k] = Y[k] = A[k]; }*/ answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:13:18: 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=1;i<A.size();i++) {
      |                 ~^~~~~~~~~
doll.cpp:10:9: warning: unused variable 'N' [-Wunused-variable]
   10 |     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...