제출 #757977

#제출 시각아이디문제언어결과실행 시간메모리
757977jer033Towers (NOI22_towers)C++17
11 / 100
663 ms32856 KiB
#include <algorithm>
#include <iostream>

long long trios[1000005];
long long xis[1000005];
long long yis[1000005];
int subt4[1000005];
char answer[1000005];

using namespace std;
long long const mult = 1000007;//10^6 + 7

int main()
{
	int n;
	cin >> n;
	if (n==3)
	{
		int a, b, c, d, e, f;
		cin >> a >> d >> b >> e >> c >> f;
		if (a==b and b==c)
		{
			if (d>e and e>f)
			{
				cout << "101";
			}
			else if (d<e and e<f)
			{
				cout << "101";
			}
			else if (e>d and d>f)
			{
				cout << "011";
			}
			else if (e<d and d<f)
			{
				cout << "011";
			}
			else if (d>f and f>e)
			{
				cout << "110";
			}
			else if (d<f and f<e)
			{
				cout << "110";
			}
		}
		else if (d==e and e==f)
		{
			if (a>b and b>c)
			{
				cout << "101";
			}
			else if (a<b and b<c)
			{
				cout << "101";
			}
			else if (b>a and a>c)
			{
				cout << "011";
			}
			else if (b<a and a<c)
			{
				cout << "011";
			}
			else if (a>c and c>b)
			{
				cout << "110";
			}
			else if (a<c and c<b)
			{
				cout << "110";
			}
		}
		else
		{
			cout << "111";
		}
		cout << '\n';
	}
	else if (n<=2)
	{
		if (n==2)
		{
			cout << "1";
		}
		cout << "1\n";
	}
	else
	{
		int four=1;
		for (int i=0; i<n; i++)
		{
			cin >> xis[i] >> yis[i];
			trios[i]=mult*mult*yis[i]+mult*xis[i]+i;
			subt4[xis[i]]++;
			if (subt4[xis[i]]>=3)
				four=0;
		}
		if (four)
		{
			for (int i=0; i<n; i++)
			{
				answer[i]='1';
			}
			sort(trios, trios+n);
			int sindex=0;
			int eindex=0;
			while (sindex<n)
			{
				while (trios[eindex]/(mult*mult) == trios[eindex+1]/(mult*mult))
				{
					eindex++;
				}
				for (int i=sindex+1; i<eindex; i++)
				{
					answer[trios[i]%mult] = '0';
				}
				sindex=eindex+1;
				eindex=sindex+1-1;
			}
			cout << answer << '\n';
		}
	}
}
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...