結果

問題 No.3779 L or R
コンテスト
ユーザー テナガザル
提出日時 2026-10-30 22:40:11
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 772 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,212 ms
コンパイル使用メモリ 174,480 KB
実行使用メモリ 9,924 KB
最終ジャッジ日時 2026-10-30 22:40:16
合計ジャッジ時間 4,930 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  string s;
  cin >> n >> s;
  if (n == 1)
  {
    if (s == "o")
    {
      cout << "No" << endl;
    }
    else
    {
      cout << "Yes" << endl;
      cout << "L" << endl;
    }
    return 0;
  }
  int cnt = 0;
  for (int i = 0; i + 1 < n; ++i) cnt += (s[i] != s[i + 1]);
  string ans(n, 'L');
  int flag = s[0] == 'x';
  flag ^= cnt % 2;
  // ans[0] = (flag ? 'L' : 'R');
  if (s[0] == s[1]) ans[0] = (flag ? 'R' : 'L');
  else ans[0] = (flag ? 'L' : 'R');
  for (int i = 1; i < n; ++i)
  {
    if (s[i - 1] == s[i]) ans[i] = (ans[i - 1] == 'L' ? 'R' : 'L');
    else ans[i] = (ans[i - 1] == 'R' ? 'R' : 'L');
  }
  cout << "Yes" << endl;
  cout << ans << endl;
}
0