답안 #301522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
301522 2020-09-18T03:43:40 Z Muhammetali 식물 비교 (IOI20_plants) C++11
컴파일 오류
0 ms 0 KB
#include "plants.h"
int h,n,arr[200001];
void init(int k, std::vector<int> r)
{
	h=k;
	n=sz(r);
	for (int i=0;i<n;i++)
	{
		if(r[i]!=k-1)arr[i]=0;
		else arr[i]=k-1;
	}
	return;
}

int compare_plants(int x, int y)
{
	if (arr[x]==0)
	{
		int g=h-1;
		int f=x+1;
		while(f<y && g>=0)
		{
			if (arr[f]==0)g=h-1;
			f++;
			g--;
		}
		if (f+1==y)return 1;
	}
	else
	{
		int g=h-1;
		int f=x+1;
		while(f<y && g>=0)
		{
			if (arr[f]==h-1)g=h-1;
			f++;
			g--;
		}
		if (f+1==y)return -1;
	}
	if (arr[y]==h-1)
	{
		int g=h-1;
		int f=y+1;
		while(f<n && g>=0)
		{
			if (arr[f]==h-1)g=h-1;
			f++;
			g--;
		}
		f=0;
		while(f<x && g>=0)
		{
			if (arr[f]==h-1)g=h-1;
			f++;
			g--;
		}
		if (f+1==x)return 1;
	}
	else
	{
		int g=h-1;
		int f=y+1;
		while(f<n && g>=0)
		{
			if (arr[f]==0)g=h-1;
			f++;
			g--;
		}
		f=0;
		while(f<x && g>=0)
		{
			if (arr[f]==0)g=h-1;
			f++;
			g--;
		}
		if (f+1==x)return -1;
	}
	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:6:4: error: 'sz' was not declared in this scope
    6 |  n=sz(r);
      |    ^~