Submission #800807

#TimeUsernameProblemLanguageResultExecution timeMemory
800807biankMechanical Doll (IOI18_doll)C++14
Compilation error
0 ms0 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; #define SIZE(x) (int)x.size() void create_circuit(int M, vector<int> A) { int N = SIZE(A); if (N == 16) { vector <int> C(M+1); vector <int> X = {-2, -4, -6, -8. -10, -12, -14, A[0], A[4], A[2], A[6], A[1], A[5], A[3], A[7]}; vector <int> Y = {-3, -5, -7, -9, -11, -13, -15, A[8], A[12]. A[10]. A[14], A[9]. A[13], A[11], A[15]}; C[0] = -1; C[A[15]] = 0; answer(C, X, Y); return 0; } vector <int> C(M+1); vector <int> X, Y; if (M == 1) { X.resize(N-1); Y.resize(N-1); C[0] = 1; if (N == 1) { C[1] = 0; answer(C,X,Y); return; } if (N == 2) { C[1] = -1; X[0] = 1; Y[0] = 0; answer(C,X,Y); return; } C[1] = -1; X[0] = 1; Y[0] = -2; for (int i=1; i<N-2; i++) { X[i] = -i; Y[i] = -i-2; //cerr << X[i] << ' ' << Y[i] << endl; } X[N-2] = -N+2; Y[N-2] = 0; } else { A.push_back(0); map <int, vector <int>> next; for (int i=0; i<N; i++) { next[A[i]].push_back(A[i+1]); //Scerr << A[i] << ' ' << A[i+1] << endl; } C[0] = A[0]; int j = 0; for (auto &x:next) { int a = x.first; vector <int> n = x.second; int S = SIZE(n); if (S == 1) { C[a] = n[0]; continue; } if (S == 2) { C[a] = --j; X.push_back(n[0]); Y.push_back(n[1]); continue; } if (S == 4) { C[a] = --j; X.push_back(--j); Y.push_back(--j); X.push_back(n[0]); Y.push_back(n[2]); X.push_back(n[1]); Y.push_back(n[3]); continue; } if (S == 3) { C[a] = --j; X.push_back(--j); Y.push_back(--j); X.push_back(n[0]); Y.push_back(n[1]); X.push_back(j+2); Y.push_back(n[2]); } } } /*for (int i=0; i<=M; i++) { cerr << C[i] << " "; } cerr << endl;*/ answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:14:98: error: narrowing conversion of '-1.8e+1' from 'double' to 'int' [-Wnarrowing]
   14 |   vector <int> X = {-2, -4, -6, -8. -10, -12, -14, A[0], A[4], A[2], A[6], A[1], A[5], A[3], A[7]};
      |                                                                                                  ^
doll.cpp:15:65: error: request for member 'A' in 'A.std::vector<int>::operator[](12)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   15 |   vector <int> Y = {-3, -5, -7, -9, -11, -13, -15, A[8], A[12]. A[10]. A[14], A[9]. A[13], A[11], A[15]};
      |                                                                 ^
doll.cpp:15:85: error: request for member 'A' in 'A.std::vector<int>::operator[](9)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   15 |   vector <int> Y = {-3, -5, -7, -9, -11, -13, -15, A[8], A[12]. A[10]. A[14], A[9]. A[13], A[11], A[15]};
      |                                                                                     ^
doll.cpp:15:104: error: could not convert '{-3, -5, -7, -9, -11, -13, -15, A.std::vector<int>::operator[](8), <expression error>, <expression error>, A.std::vector<int>::operator[](11), A.std::vector<int>::operator[](15)}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   15 |   vector <int> Y = {-3, -5, -7, -9, -11, -13, -15, A[8], A[12]. A[10]. A[14], A[9]. A[13], A[11], A[15]};
      |                                                                                                        ^
      |                                                                                                        |
      |                                                                                                        <brace-enclosed initializer list>
doll.cpp:19:10: error: return-statement with a value, in function returning 'void' [-fpermissive]
   19 |   return 0;
      |          ^