Submission #787046

#TimeUsernameProblemLanguageResultExecution timeMemory
787046APROHACKMechanical Doll (IOI18_doll)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "doll.h" #define ll long long #define pb push_back #define ff first #define ss second using namespace std; int n, m, cur; vector<int>c, x, y; vector<int>a; int generar(int desde, int cada, int div, bool lastt){ if(div == 0){ return a[desde]; } if(a[desde] == -1 and ! lastt){ return a[desde]; } int posi = cur; int real = -(cur + 1); x.pb(0); y.pb(0); cur ++ ; x[posi] = generar(desde, cada*2, div-1, false); y[posi] = generar(desde + cada, cada*2, div-1, lastt); return real; } void create_circuit(int M, std::vector<int> A) { cur = 0; a = A; n = A.size(); m = M; c.pb(A[0]); for(int i = 1 ; i <= M ; i ++)c.pb(-1); int k = 1, pot = 0; while(k <= a.size()-1 ){ k *= 2; pot ++; } while(a.size()-1 < k)a.pb(-1); a.pop_back(); a.push_back(0); c[A[0]] = generar(1, 1, pot, true); answer(c, x, y); } #include <bits/stdc++.h> #include "doll.h" #define ll long long #define pb push_back #define ff first #define ss second using namespace std; int n, m, cur; vector<int>c, x, y; vector<int>a; int generar(int desde, int cada, int div, bool lastt){ if(div == 0){ return a[desde]; } if(a[desde] == -1 and ! lastt){ return a[desde]; } int posi = cur; int real = -(cur + 1); x.pb(0); y.pb(0); cur ++ ; x[posi] = generar(desde, cada*2, div-1, false); y[posi] = generar(desde + cada, cada*2, div-1, lastt); return real; } void create_circuit(int M, std::vector<int> A) { cur = 0; a = A; n = A.size(); m = M; c.pb(A[0]); for(int i = 1 ; i <= M ; i ++)c.pb(-1); int k = 1, pot = 0; while(k <= a.size()-1 ){ k *= 2; pot ++; } while(a.size()-1 < k)a.pb(-1); a.pop_back(); a.push_back(0); c[A[0]] = generar(1, 1, pot, true); answer(c, x, y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:39:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  while(k <= a.size()-1 ){
      |        ~~^~~~~~~~~~~~~
doll.cpp:43:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |  while(a.size()-1 < k)a.pb(-1);
      |        ~~~~~~~~~~~^~~
doll.cpp: At global scope:
doll.cpp:57:5: error: redefinition of 'int n'
   57 | int n, m, cur;
      |     ^
doll.cpp:8:5: note: 'int n' previously declared here
    8 | int n, m, cur;
      |     ^
doll.cpp:57:8: error: redefinition of 'int m'
   57 | int n, m, cur;
      |        ^
doll.cpp:8:8: note: 'int m' previously declared here
    8 | int n, m, cur;
      |        ^
doll.cpp:57:11: error: redefinition of 'int cur'
   57 | int n, m, cur;
      |           ^~~
doll.cpp:8:11: note: 'int cur' previously declared here
    8 | int n, m, cur;
      |           ^~~
doll.cpp:59:12: error: redefinition of 'std::vector<int> c'
   59 | vector<int>c, x, y;
      |            ^
doll.cpp:10:12: note: 'std::vector<int> c' previously declared here
   10 | vector<int>c, x, y;
      |            ^
doll.cpp:59:15: error: redefinition of 'std::vector<int> x'
   59 | vector<int>c, x, y;
      |               ^
doll.cpp:10:15: note: 'std::vector<int> x' previously declared here
   10 | vector<int>c, x, y;
      |               ^
doll.cpp:59:18: error: redefinition of 'std::vector<int> y'
   59 | vector<int>c, x, y;
      |                  ^
doll.cpp:10:18: note: 'std::vector<int> y' previously declared here
   10 | vector<int>c, x, y;
      |                  ^
doll.cpp:60:12: error: redefinition of 'std::vector<int> a'
   60 | vector<int>a;
      |            ^
doll.cpp:11:12: note: 'std::vector<int> a' previously declared here
   11 | vector<int>a;
      |            ^
doll.cpp:62:5: error: redefinition of 'int generar(int, int, int, bool)'
   62 | int generar(int desde, int cada, int div, bool lastt){
      |     ^~~~~~~
doll.cpp:13:5: note: 'int generar(int, int, int, bool)' previously defined here
   13 | int generar(int desde, int cada, int div, bool lastt){
      |     ^~~~~~~
doll.cpp:80:6: error: redefinition of 'void create_circuit(int, std::vector<int>)'
   80 | void create_circuit(int M, std::vector<int> A) {
      |      ^~~~~~~~~~~~~~
doll.cpp:31:6: note: 'void create_circuit(int, std::vector<int>)' previously defined here
   31 | void create_circuit(int M, std::vector<int> A) {
      |      ^~~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:88:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |  while(k <= a.size()-1 ){
      |        ~~^~~~~~~~~~~~~
doll.cpp:92:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   92 |  while(a.size()-1 < k)a.pb(-1);
      |        ~~~~~~~~~~~^~~