Submission #20900472


Source Code Expand

#include <cstdio>
using namespace std;

const int max_n = 200000;
char s[max_n+1], op[max_n+1];
bool wn[7] = {}, nwn[7];

int main()
{
	int n, cur = 1;
	bool sl1, sl2;

	scanf("%d%s%s", &n, s, op);
	wn[0] = true;

	for (int i = n - 1; i >= 0; i--)
	{
		for (int j = 0; j < 7; j++)
			nwn[j] = wn[j];

		if (op[i] == 'A')
		{
			for (int j = 0; j < 7; j++)
				if (!wn[(j+cur*(s[i]-'0'))%7])
					nwn[j] = false;
		}
		else
		{
			for (int j = 0; j < 7; j++)
				if (wn[(j+cur*(s[i]-'0'))%7])
					nwn[j] = true;
		}

		sl1 = true, sl2 = false;
		for (int j = 0; j < 7; j++)
		{
			wn[j] = nwn[j];
			sl1 &= wn[j], sl2 |= wn[j];
		}

		if (sl1)
		{
			puts("Takahashi");
			return 0;
		}
		else if (!sl2)
		{
			puts("Aoki");
			return 0;
		}

		cur = (cur * 10) % 7;
	}

	if (wn[0])
		puts("Takahashi");
	else
		puts("Aoki");

	return 0;
}

Submission Info

Submission Time
Task E - Lucky 7 Battle
User fiveAB
Language C++ (GCC 9.2.1)
Score 500
Code Size 899 Byte
Status AC
Exec Time 16 ms
Memory 1860 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   13 |  scanf("%d%s%s", &n, s, op);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 4
AC × 37
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_31.txt, random_32.txt, random_33.txt, random_41.txt, random_42.txt, random_43.txt, random_44.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
hand_01.txt AC 2 ms 1624 KiB
hand_02.txt AC 2 ms 1592 KiB
hand_03.txt AC 1 ms 1620 KiB
hand_04.txt AC 2 ms 1596 KiB
random_01.txt AC 2 ms 1704 KiB
random_02.txt AC 3 ms 1780 KiB
random_03.txt AC 3 ms 1792 KiB
random_04.txt AC 2 ms 1668 KiB
random_05.txt AC 2 ms 1816 KiB
random_06.txt AC 1 ms 1708 KiB
random_11.txt AC 12 ms 1792 KiB
random_12.txt AC 7 ms 1748 KiB
random_13.txt AC 16 ms 1860 KiB
random_14.txt AC 11 ms 1720 KiB
random_15.txt AC 14 ms 1812 KiB
random_16.txt AC 6 ms 1756 KiB
random_17.txt AC 10 ms 1712 KiB
random_18.txt AC 12 ms 1624 KiB
random_19.txt AC 11 ms 1820 KiB
random_20.txt AC 8 ms 1736 KiB
random_21.txt AC 14 ms 1804 KiB
random_22.txt AC 11 ms 1788 KiB
random_23.txt AC 12 ms 1708 KiB
random_24.txt AC 11 ms 1760 KiB
random_25.txt AC 12 ms 1816 KiB
random_26.txt AC 6 ms 1624 KiB
random_31.txt AC 7 ms 1796 KiB
random_32.txt AC 9 ms 1768 KiB
random_33.txt AC 7 ms 1708 KiB
random_41.txt AC 2 ms 1816 KiB
random_42.txt AC 2 ms 1816 KiB
random_43.txt AC 8 ms 1844 KiB
random_44.txt AC 13 ms 1788 KiB
sample_01.txt AC 1 ms 1616 KiB
sample_02.txt AC 1 ms 1616 KiB
sample_03.txt AC 1 ms 1520 KiB
sample_04.txt AC 1 ms 1644 KiB