Submission #542800

#TimeUsernameProblemLanguageResultExecution timeMemory
542800Sho10Mechanical Doll (IOI18_doll)C++14
0 / 100
173 ms262144 KiB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho #include "doll.h" using ll=int; using ld=long double; int const INF=1000000005; //ll const LINF=1000000000000000005; ll const mod=1000000007; ld const PI=3.14159265359; #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define f first #define s second #define pb push_back #define mp make_pair #define endl '\n' #define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; ll lt[1000005],rt[1000005],cnt=0,switches=0,val=0,nr=0,ans[1000005],b[1000005]; ll build(ll node,ll realnodes){ if(realnodes==0){ return -1; } if(node==1){ return (nr++); } ll centr=-(++switches); lt[-centr]=build(node/2,realnodes-min(node/2,realnodes)); rt[-centr]=build(node/2,min(node/2,realnodes)); return centr; } ll dfs(ll node){ if(node>=0){ return node; } b[-node]=!b[-node]; if(b[-node]==1){ dfs(lt[-node]); }else dfs(rt[-node]); } void create_circuit(int M,vector<int>A){ vector<int>C(M+1); vector<int>a; for(ll i=0;i<A.size();i++) { a.pb(i); } C[0]=-1; for(int i=1;i<=M;i++) { C[i]=-1; } a.pb(0); ll x=a.size(); nr=0; ll nodes=1; while(nodes<x){ nodes*=2; } x=build(nodes,a.size()); for(ll i=0;i<a.size();i++) { ans[dfs(-1)]=a[i]; } vector<int> X(switches),Y(switches); for(ll i=1;i<=switches;i++) { X[i-1]=lt[i]; Y[i-1]=rt[i]; if(X[i-1]>=0){ X[i-1]=ans[X[i-1]]; } if(Y[i-1]>=0){ Y[i-1]=ans[Y[i-1]]; } } answer(C,X,Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:43:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 | for(ll i=0;i<A.size();i++)
      |            ~^~~~~~~~~
doll.cpp:60:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 | for(ll i=0;i<a.size();i++)
      |            ~^~~~~~~~~
doll.cpp: In function 'll dfs(ll)':
doll.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
   39 | }
      | ^
#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...