結果

問題 No.3395 Range Flipping Game
コンテスト
ユーザー pengin_2000
提出日時 2025-12-04 03:39:20
言語 C
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 621 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 428 ms
コンパイル使用メモリ 26,320 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-12-04 03:39:27
合計ジャッジ時間 5,447 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14 RE * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘solve’:
main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%s", s);
      |         ^~~~~~~~~~~~~~
main.c: In function ‘main’:
main.c:45:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |         scanf("%d", &t);
      |         ^~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include<stdio.h>
char s[200005];
void solve()
{
	int n;
	scanf("%d", &n);
	scanf("%s", s);
	if (s[1] == '\0')
	{
		printf("B\n");
		return;
	}
	int i;
	if (s[0] == 'A')
	{
		if (s[1] == 'A')
		{
			s[0] = s[1] = 'B';
			for (i = 2; s[i] == 'B'; i++)
				s[i] = 'A';
		}
		else
		{
			s[0] = 'B';
			for (i = 2; s[i] != '\0' && s[i] == 'A'; i++);
			for (; s[i] == 'B'; i++)
				s[i] = 'A';
		}
	}
	else
	{
		if (s[1] == 'A')
		{
			s[0] = s[1] = 'B';
			for (i = 2; s[i] == 'B'; i++)
				s[i] = 'A';
		}
	}
	printf("%s\n", s);
	return;
}
int main()
{
	int t;
	scanf("%d", &t);
	for (; t > 0; t--)
		solve();
	return 0;
}
0