답안 #714551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
714551 2023-03-25T02:50:13 Z firewater 자동 인형 (IOI18_doll) C++14
컴파일 오류
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);
      |  ^~~~~~