Submission #757986

# Submission time Handle Problem Language Result Execution time Memory
757986 2023-06-14T04:04:52 Z jer033 Towers (NOI22_towers) C++17
18 / 100
708 ms 29860 KB
#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

long long inde(long long a, long long b, long long x, long long y)
{
	b=0;
	return (x-1)*a+y+b-1;//yeah b isn't really needed after all
}

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;
		long long b=0;
		long long a=0;
		for (int i=0; i<n; i++)
		{
			cin >> xis[i] >> yis[i];
			b=max(b, xis[i]);
			a=max(a, 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';
		}
		else
		{
			//assume this is subtask 3, then we already have our values of b and a
			for (int i=0; i<n; i++)
			{
				answer[i]='0';
			}
			if (a==b)
			{
				for (int i=1; i<=a; i++)
				{
					answer[inde(a, b, i, i)]='1';
					answer[inde(a, b, i, a+1-i)]='1';
				}
			}
			else if (a>b)
			{
				for (long long i=1; i<=b; i++)
				{
					answer[inde(a, b, i, min(i, b+1-i))]='1';
					answer[inde(a, b, i, a+1-min(i, b+1-i))]='1';
				}
			}
			else
			{
				for (long long i=1; i<=a; i++)
				{
					answer[inde(a, b, min(i, a+1-i), i)]='1';
					answer[inde(a, b, b+1-min(i, a+1-i), i)]='1';
				}
			}
			cout << answer << '\n';
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Runtime error 1 ms 468 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 2564 KB Output is correct
2 Correct 46 ms 3128 KB Output is correct
3 Correct 135 ms 9208 KB Output is correct
4 Correct 252 ms 18852 KB Output is correct
5 Correct 50 ms 3636 KB Output is correct
6 Correct 14 ms 980 KB Output is correct
7 Correct 244 ms 16944 KB Output is correct
8 Correct 182 ms 11344 KB Output is correct
9 Correct 393 ms 26108 KB Output is correct
10 Correct 318 ms 21440 KB Output is correct
11 Correct 395 ms 27208 KB Output is correct
12 Correct 421 ms 26988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 598 ms 29664 KB Output is correct
2 Correct 607 ms 29752 KB Output is correct
3 Correct 651 ms 29808 KB Output is correct
4 Correct 627 ms 29820 KB Output is correct
5 Correct 628 ms 29744 KB Output is correct
6 Correct 708 ms 29748 KB Output is correct
7 Correct 649 ms 29860 KB Output is correct
8 Correct 668 ms 29820 KB Output is correct
9 Correct 685 ms 29764 KB Output is correct
10 Correct 651 ms 29748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Runtime error 1 ms 468 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Runtime error 1 ms 468 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Runtime error 1 ms 468 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -