Submission #424140

#TimeUsernameProblemLanguageResultExecution timeMemory
424140A_DMechanical Doll (IOI18_doll)C++14
0 / 100
1 ms204 KiB
#include "doll.h"
#include <bits/stdc++.h>
#define ii pair<int,int>
#define F first
#define S second
using namespace std;
const int NN=3e5+100;
vector<int> c,x,y,a;
int sz;
void build(int p,int l,int sum)
{
    if(sum*2>=sz){
        x[p-1]=a[l];
        y[p-1]=a[l+sum];
        return;
    }
    x[p-1]=(-(p*2));
    y[p-1]=(-(p*2+1));
    build(p*2,l,sum*2);
    build(p*2+1,l+sum,sum*2);
}
void create_circuit(int m,vector<int>A){
    a=A;
    sz=a.size();
    if(a.size()==1){
        c.push_back(a[0]);
        for(int i=1;i<=m;i++)c.push_back(0);
        answer(c,x,y);
        return;
    }
    for(int i=0;i<=m;i++){
        c.push_back(-1);
    }
    sz++;
    a.push_back(-1);
    while(1){
        int u=log2(sz);
        int v=log2(sz-1);
        if(u>v){
            break;
        }
        sz++;
        a.push_back(-1);
    }
    a.pop_back();
    a.push_back(0);
    x.resize(sz*2);
    y.resize(sz*2);
    build(1,0,1);
    while(x.back()==y.back()&&x.back()==0){
        x.pop_back();
        y.pop_back();
    }

    cout<<sz<<endl;
    for(auto x:c)cout<<x<<" ";cout<<endl;
    for(auto xx:x)cout<<xx<<" ";cout<<endl;
    for(auto x:y)cout<<x<<" ";cout<<endl;

    answer(c,x,y);
}

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:56:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   56 |     for(auto x:c)cout<<x<<" ";cout<<endl;
      |     ^~~
doll.cpp:56:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   56 |     for(auto x:c)cout<<x<<" ";cout<<endl;
      |                               ^~~~
doll.cpp:57:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   57 |     for(auto xx:x)cout<<xx<<" ";cout<<endl;
      |     ^~~
doll.cpp:57:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   57 |     for(auto xx:x)cout<<xx<<" ";cout<<endl;
      |                                 ^~~~
doll.cpp:58:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   58 |     for(auto x:y)cout<<x<<" ";cout<<endl;
      |     ^~~
doll.cpp:58:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   58 |     for(auto x:y)cout<<x<<" ";cout<<endl;
      |                               ^~~~
#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...