Submission #146110

# Submission time Handle Problem Language Result Execution time Memory
146110 2019-08-22T08:37:47 Z TadijaSebez cmp (balkan11_cmp) C++11
100 / 100
1713 ms 82672 KB
#include "cmp.h"

void remember(int a)
{
	int x=a>>6&63;
	int y=a>>9&7;
	int z=a>>3&7;
	int o=a&7;
	bit_set(x+1);
	bit_set(y+65);
	bit_set(z+73);
	bit_set(o+81);
}

int compare(int b)
{
	int x=b>>6&63;
	int y=b>>9&7;
	int z=b>>3&7;
	int o=b&7;
	int p=b>>6&7;
	if(bit_get(x+1))
	{
		if(bit_get(z+73))
		{
			if(bit_get(o+81)) return 0;
			else
			{
				if(o>3)
				{
					for(int i=o+1;i<8;i++) if(bit_get(i+81)) return -1;
					return 1;
				}
				else
				{
					for(int i=o-1;i>=0;i--) if(bit_get(i+81)) return 1;
					return -1;
				}
			}
		}
		else
		{
			if(z>3)
			{
				for(int i=z+1;i<8;i++) if(bit_get(i+73)) return -1;
				return 1;
			}
			else
			{
				for(int i=z-1;i>=0;i--) if(bit_get(i+73)) return 1;
				return -1;
			}
		}
	}
	else
	{
		if(bit_get(y+65))
		{
			if(p>3)
			{
				for(int i=p+1;i<8;i++) if(bit_get(y*8+i+1)) return -1;
				return 1;
			}
			else
			{
				for(int i=p-1;i>=0;i--) if(bit_get(y*8+i+1)) return 1;
				return -1;
			}
		}
		else
		{
			if(y>3)
			{
				for(int i=y+1;i<8;i++) if(bit_get(i+65)) return -1;
				return 1;
			}
			else
			{
				for(int i=y-1;i>=0;i--) if(bit_get(i+65)) return 1;
				return -1;
			}
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1713 ms 82672 KB Output is correct - maxAccess = 10, score = 100