Submission #1193013

#TimeUsernameProblemLanguageResultExecution timeMemory
1193013zyntherixSquare or Rectangle? (NOI19_squarerect)C++20
100 / 100
0 ms328 KiB
#include "squarerect.h"
#include <bits/stdc++.h>
using namespace std;

bool am_i_square(int N, int Q)
{
	int x = -1, y = -1;
	for (int i = 20; i <= 80; i += 20)
	{
		for (int j = 20; j <= 80; j += 20)
		{
			if (inside_shape(i, j))
			{
				x = i;
				y = j;
				break;
			}
		}
		if (x != -1)
			break;
	}
	if (x != -1)
	{
		int x2 = x - 20;
		int l = x;
		int r = x2;
		while (r < l - 1)
		{
			int m = (l + r) / 2;
			if (inside_shape(m, y))
			{
				l = m;
			}
			else
			{
				r = m;
			}
		}
		x = l;
		int y2 = y - 20;
		l = y;
		r = y2;
		while (r < l - 1)
		{
			int m = (l + r) / 2;
			if (inside_shape(x, m))
			{
				l = m;
			}
			else
			{
				r = m;
			}
		}
		y = l;
		l = y;
		r = 101;
		while (l + 1 < r)
		{
			int m = (l + r) / 2;
			if (inside_shape(x, m))
			{
				l = m;
			}
			else
			{
				r = m;
			}
		}
		y2 = l;
		x2 = x + (y2 - y);
		if ((x2 <= 100 && inside_shape(x2, y)) && ((x2 + 1 > 100) || !inside_shape(x2 + 1, y)))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	for (int i = 20; i <= 100; i += 20)
	{
		if (inside_shape(i, 100))
		{
			x = i;
			y = 100;
			break;
		}
	}
	if (x != -1)
	{
		int l = x;
		int r = x - 20;
		while (r < l - 1)
		{
			int m = (l + r) / 2;
			if (inside_shape(m, 100))
			{
				l = m;
			}
			else
			{
				r = m;
			}
		}
		x = l;
		int x2 = l + 19;
		int y2 = 81;
		if (inside_shape(x2, 100) && inside_shape(x2, y2) && (x2 != 100 || !inside_shape(x2 + 1, 100)))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	for (int i = 40; i <= 100; i += 20)
	{
		if (inside_shape(100, i))
		{
			x = 100;
			y = i;
			break;
		}
	}
	if (x == -1)
	{
		return false;
	}
	int l = y;
	int r = y - 20;
	while (r < l - 1)
	{
		int m = (l + r) / 2;
		if (inside_shape(100, m))
		{
			l = m;
		}
		else
		{
			r = m;
		}
	}
	y = l;
	int y2 = y + 19;
	if (inside_shape(100, y2) && inside_shape(81, y) && (y2 != 100 || !inside_shape(100, y2 + 1)))
	{
		return true;
	}
	else
	{
		return false;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...