結果

問題 No.3779 L or R
コンテスト
ユーザー pengin_2000
提出日時 2026-10-30 21:53:10
言語 C
(gcc 15.3.0)
コンパイル:
gcc-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
+ 595µs
コード長 684 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 469 ms
コンパイル使用メモリ 43,992 KB
実行使用メモリ 9,908 KB
最終ジャッジ日時 2026-10-30 21:53:18
合計ジャッジ時間 3,684 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>
char s[200005];
int a[200005];
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	scanf("%s", s);
	for (i = 0; i < n; i++)
	{
		if (s[i] == 'o')
			a[i] = 1;
		else
			a[i] = 0;
	}
	int f = 0;
	s[0] = 'L';
	int x, y;
	x = a[0] ^ 1;
	for (i = 1; i < n; i++)
	{
		y = a[i] ^ f;
		if (x == y)
			s[i] = 'L';
		else
		{
			s[i] = 'R';
			f ^= 1;
		}
		x = y ^ 1;
	}
	if (x > 0)
	{
		printf("Yes\n%s\n", s);
		return 0;
	}
	f = 1;
	s[0] = 'R';
	x = a[0] ^ 1;
	for (i = 1; i < n; i++)
	{
		y = a[i] ^ f;
		if (x == y)
			s[i] = 'L';
		else
		{
			s[i] = 'R';
			f ^= 1;
		}
		x = y ^ 1;
	}
	if (x > 0)
	{
		printf("Yes\n%s\n", s);
		return 0;
	}
	printf("No\n");
	return 0;
}
0