Submission #29880191


Source Code Expand

#include<cstdio>
#include<cstring>
using ll = long long;
char s[111111];
inline char DFS(const char c, const ll a, const ll b)
{
	if (a == 0)
	{
		return c;
	}
	if (b > 1ll << (a - 1))
	{
		return DFS(c == 'A' ? 'C' : c == 'B' ? 'A' : 'B', a - 1, b - (1ll << (a - 1)));
	}
	return DFS(c == 'A' ? 'B' : c == 'B' ? 'C' : 'A', a - 1, b);
}
int main()
{
	int q;
	scanf("%s%d", s + 1, &q);
	const int n = strlen(s + 1);
	for (int i = 1; i <= q; ++i)
	{
		ll a, b;
		scanf("%lld%lld", &a, &b);
		if (a >= 62)
		{
			printf("%c", DFS((s[1] - 'A' + (a - 63)) % 3 + 'A', 63, b));
		}
		else
		{
			printf("%c", DFS(s[(b - 1) / (1ll << a) + 1], a, (b - 1) % (1ll << a) + 1));
		}
		puts("");
	}
	return 0;
}

Submission Info

Submission Time
Task D - ABC Transform
User LXl491214
Language C++ (GCC 9.2.1)
Score 400
Code Size 733 Byte
Status AC
Exec Time 67 ms
Memory 1772 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:12: warning: unused variable ‘n’ [-Wunused-variable]
   21 |  const int n = strlen(s + 1);
      |            ^
./Main.cpp:20:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   20 |  scanf("%s%d", s + 1, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
./Main.cpp:25:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   25 |   scanf("%lld%lld", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 24
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 5 ms 1620 KiB
001.txt AC 2 ms 1732 KiB
002.txt AC 66 ms 1604 KiB
003.txt AC 67 ms 1696 KiB
004.txt AC 44 ms 1704 KiB
005.txt AC 51 ms 1624 KiB
006.txt AC 46 ms 1760 KiB
007.txt AC 50 ms 1660 KiB
008.txt AC 54 ms 1616 KiB
009.txt AC 56 ms 1616 KiB
010.txt AC 59 ms 1708 KiB
011.txt AC 56 ms 1516 KiB
012.txt AC 55 ms 1708 KiB
013.txt AC 44 ms 1620 KiB
014.txt AC 42 ms 1772 KiB
015.txt AC 43 ms 1516 KiB
016.txt AC 46 ms 1624 KiB
017.txt AC 43 ms 1700 KiB
018.txt AC 42 ms 1708 KiB
019.txt AC 43 ms 1624 KiB
020.txt AC 43 ms 1524 KiB
021.txt AC 43 ms 1660 KiB
example0.txt AC 5 ms 1508 KiB
example1.txt AC 2 ms 1676 KiB