Submission #714551

# Submission time Handle Problem Language Result Execution time Memory
714551 2023-03-25T02:50:13 Z firewater Mechanical Doll (IOI18_doll) C++14
Compilation error
0 ms 0 KB
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include <vector>
#define ll long long
#define N 202300
//#include "doll.h"
using namespace std;
vector<int>ans,P,Q;
int w,n,nn,a[N];
int dfs(int L,int R,int l,int r)
{
	if(l==r){
		if(l==1){
			ans[a[++w]]=0;
			return a[w];
		}
		return a[++w];
	}
	int x=P.size(),mid=L+R>>1;
	P.push_back(0);
	Q.push_back(0);
	if(r<=mid){
		Q[x]=-1;
		P[x]=dfs(L,mid,l,r);
	}
	else{
		Q[x]=dfs(mid+1,R,mid+1,r);
		P[x]=dfs(L,mid,l,mid);
	}
	return -x-1;
}
void create_circuit(int M, std::vector<int> A)
{
	n=A.size();
	for(int i=1;i<=n;++i)
		a[i]=A[i-1];
	nn=1;
	while(nn<n)nn<<=1;
	
	
	if(n==1){
		ans.push_back(a[1]);
		for(int i=1;i<=M;++i)
			ans.push_back(0);
	}
	else{
		for(int i=0;i<=M;++i)
			ans.push_back(-1);
		dfs(1,nn,1,n);
	}
	answer(ans,P,Q);
	return;
}

Compilation message

doll.cpp: In function 'int dfs(int, int, int, int)':
doll.cpp:21:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   21 |  int x=P.size(),mid=L+R>>1;
      |                     ~^~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:53:2: error: 'answer' was not declared in this scope
   53 |  answer(ans,P,Q);
      |  ^~~~~~