Submission #7559876


Source Code Expand

Copy
#include <cstdio>
const int MAXN=220000;
char s[MAXN];
int main()
{
//	freopen("D.in", "r", stdin);
//	freopen("D.out", "w", stdout);
	int n, k;
	scanf("%d%d%s", &n, &k, s+1);
	if (k<=100*n)
	{
		int p=1, f=0;
		for (int i=1; i<=k; i++)
			if (f^s[p]=='A') s[p]=f?'A':'B';
			else f^=1, p=p==n?1:p+1;
		for (int i=p, j=1; j<=n; i=i==n?1:i+1, j++)
			if (!f) putchar(s[i]);
			else putchar(s[i]=='A'?'B':'A');
	}
	else
	{
		if (n==1)
		{
			if (k%2==0) putchar(s[1]);
			else putchar(s[1]=='A'?'B':'A');
		}
		else if (n%2==0)
			for (int i=1, f=0; i<=n; i++, f^=1) putchar(f?'A':'B');
		else if (k%2==0)
			for (int i=1, f=1; i<=n; i++, f^=1) putchar(f?'A':'B');
		else
		{
			putchar('B');
			for (int i=2, f=0; i<=n; i++, f^=1) putchar(f?'A':'B');
		}
	}
	putchar('\n');
	return 0;
}

Submission Info

Submission Time
Task D - Half Reflector
User luogu_bot4
Language C++ (GCC 5.4.1)
Score 0
Code Size 823 Byte
Status
Exec Time 4 ms
Memory 512 KB

Compile Error

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

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 0 / 900 sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in38.txt, in39.txt, in4.txt, in40.txt, in41.txt, in42.txt, in5.txt, in543.txt, in557.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
in1.txt 1 ms 128 KB
in10.txt 3 ms 512 KB
in11.txt 4 ms 512 KB
in12.txt 3 ms 512 KB
in13.txt 3 ms 512 KB
in14.txt 4 ms 512 KB
in15.txt 3 ms 512 KB
in16.txt 3 ms 512 KB
in17.txt 4 ms 512 KB
in18.txt 4 ms 512 KB
in19.txt 3 ms 512 KB
in2.txt 2 ms 384 KB
in20.txt 4 ms 512 KB
in21.txt 4 ms 512 KB
in22.txt 3 ms 512 KB
in23.txt 3 ms 512 KB
in24.txt 3 ms 512 KB
in25.txt 3 ms 512 KB
in26.txt 3 ms 512 KB
in27.txt 3 ms 512 KB
in28.txt 3 ms 512 KB
in29.txt 3 ms 512 KB
in3.txt 4 ms 512 KB
in30.txt 3 ms 512 KB
in31.txt 3 ms 512 KB
in32.txt 4 ms 512 KB
in33.txt 4 ms 512 KB
in34.txt 4 ms 512 KB
in35.txt 4 ms 512 KB
in36.txt 4 ms 512 KB
in37.txt 4 ms 512 KB
in38.txt 4 ms 512 KB
in39.txt 3 ms 512 KB
in4.txt 3 ms 512 KB
in40.txt 3 ms 512 KB
in41.txt 3 ms 512 KB
in42.txt 3 ms 512 KB
in5.txt 3 ms 512 KB
in543.txt 3 ms 512 KB
in557.txt 3 ms 512 KB
in6.txt 1 ms 128 KB
in7.txt 4 ms 512 KB
in8.txt 3 ms 512 KB
in9.txt 4 ms 512 KB
sample1.txt 1 ms 128 KB
sample2.txt 1 ms 128 KB
sample3.txt 1 ms 128 KB