Submission #775324

# Submission time Handle Problem Language Result Execution time Memory
775324 2023-07-06T09:39:53 Z I_Love_EliskaM_ Mechanical Doll (IOI18_doll) C++14
Compilation error
0 ms 0 KB
void create_circuit(int m, vector<int>a) {
  vector<int> c(m+1,-1); c[0]=a[0];
  int n=a.size();
  int sz=1; while (sz<n) sz<<=1;
  vector<int> x(2*sz-1,-1), y(2*sz-1,-1);
  forn(i,sz-1) x[i]=2*i+1, y[i]=2*i+2;
  forn(i,sz-1) x[i]=-1-x[i], y[i]=-1-y[i];
  vector<int> s(2*sz-1,1);

  vector<pi> z;
  forn(it,2*sz) {
    int p=0;
    while (p<sz-1) {
      s[p]^=1;
      p=2*p+1+s[p];
    }
    z.pb({p,s[p]});
    s[p]^=1;
  }
  
  forn(i,n-1) {
    if (z[i].s) y[z[i].f]=a[i+1];
    else x[z[i].f]=a[i+1];
  }
  y[z.back().f]=0;

  answer(c,x,y);
}

Compilation message

doll.cpp:1:28: error: 'vector' has not been declared
    1 | void create_circuit(int m, vector<int>a) {
      |                            ^~~~~~
doll.cpp:1:34: error: expected ',' or '...' before '<' token
    1 | void create_circuit(int m, vector<int>a) {
      |                                  ^
doll.cpp: In function 'void create_circuit(int, int)':
doll.cpp:2:3: error: 'vector' was not declared in this scope
    2 |   vector<int> c(m+1,-1); c[0]=a[0];
      |   ^~~~~~
doll.cpp:2:10: error: expected primary-expression before 'int'
    2 |   vector<int> c(m+1,-1); c[0]=a[0];
      |          ^~~
doll.cpp:2:26: error: 'c' was not declared in this scope
    2 |   vector<int> c(m+1,-1); c[0]=a[0];
      |                          ^
doll.cpp:2:31: error: 'a' was not declared in this scope
    2 |   vector<int> c(m+1,-1); c[0]=a[0];
      |                               ^
doll.cpp:5:10: error: expected primary-expression before 'int'
    5 |   vector<int> x(2*sz-1,-1), y(2*sz-1,-1);
      |          ^~~
doll.cpp:6:8: error: 'i' was not declared in this scope
    6 |   forn(i,sz-1) x[i]=2*i+1, y[i]=2*i+2;
      |        ^
doll.cpp:6:3: error: 'forn' was not declared in this scope
    6 |   forn(i,sz-1) x[i]=2*i+1, y[i]=2*i+2;
      |   ^~~~
doll.cpp:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> s(2*sz-1,1);
      |          ^~~
doll.cpp:10:10: error: 'pi' was not declared in this scope
   10 |   vector<pi> z;
      |          ^~
doll.cpp:10:14: error: 'z' was not declared in this scope; did you mean 'sz'?
   10 |   vector<pi> z;
      |              ^
      |              sz
doll.cpp:11:8: error: 'it' was not declared in this scope; did you mean 'int'?
   11 |   forn(it,2*sz) {
      |        ^~
      |        int
doll.cpp:25:3: error: 'y' was not declared in this scope
   25 |   y[z.back().f]=0;
      |   ^
doll.cpp:27:12: error: 'x' was not declared in this scope
   27 |   answer(c,x,y);
      |            ^
doll.cpp:27:3: error: 'answer' was not declared in this scope
   27 |   answer(c,x,y);
      |   ^~~~~~