Submission #101910

#TimeUsernameProblemLanguageResultExecution timeMemory
101910daniel920712Mechanical Doll (IOI18_doll)C++14
10 / 100
1082 ms380 KiB
#include "doll.h" #include <vector> #include <stdio.h> using namespace std; int con[1000005]={0}; int This[1000005]={0}; int m[1000005]; int n[1000005]; int start[1000005]={0}; vector < int > C,x,y; int X[1000005]={0}; int Y[1000005]={0}; int now=1; int t[1000005]={0}; int how[1000005]={0}; void build(int N,int here,int where) { //printf("%d %d\n",N,here); if(where) { X[-here]=where; Y[-here]=(-now); now++; build(N,Y[-here],0); } else if(N==2) { X[-here]=0; Y[-here]=0; } else if(N==1) { X[-here]=here; Y[-here]=0; } else if(N%2==0) { X[-here]=(-now); now++; Y[-here]=(-now); now++; build(N/2,X[-here],0); build(N/2,Y[-here],0); } else { X[-here]=(-now); now++; Y[-here]=(-now); now++; build(N/2,X[-here],here); build(N/2+1,Y[-here],0); } } void New(int here,int what) { if(how[-here]%2==0) { how[-here]++; if(X[-here]) New(X[-here],what); else X[-here]=what; } else { how[-here]++; if(Y[-here]) New(Y[-here],what); else Y[-here]=what; } } void create_circuit(int M, vector < int > A) { int N=A.size(),i,temp; C.push_back(A[0]); for(i=1;i<=M;i++) C.push_back(i); for(i=0;i<N;i++) con[A[i]]++; A.push_back(0); now++; build(N,-1,0); for(i=0;i<N;i++) { C[A[i]]=-1; New(C[A[i]],A[i+1]); } //printf("a %d\n",now-1); //for(auto i:C) printf("%d ",i); //printf("\n"); //for(i=1;i<now;i++) printf("%d %d\n",X[i],Y[i]); for(i=1;i<now;i++) x.push_back(X[i]); for(i=1;i<now;i++) y.push_back(Y[i]); answer(C,x,y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:79:22: warning: unused variable 'temp' [-Wunused-variable]
   79 |     int N=A.size(),i,temp;
      |                      ^~~~
#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...