結果

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

ソースコード

diff #
raw source code

//yukicoder No.3779
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision ?
#include <numeric>
#include <iterator>
#include <random>
#include <assert.h>
//#include <stdlib.h>
using namespace std;
typedef int64_t ll;

//出力
void print(bool b){
  if(b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return;
}
void print(vector<int> V){
  for(auto i=V.begin();i!=V.end();i++)cout<<*i<<(next(i)==V.end() ? "" : " ");
  cout<<endl;
  return;
}
void print(vector<vector<int>> V){
  for(auto &v:V)print(v);
  return;
}

//ここまでがテンプレーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
int n;


int main(){//main関数ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
  string s; cin>>n>>s;
  vector<bool> V(n);
  V.at(0)= (s.at(0)=='o');//一番左だけは、実際に点灯しているかを記録
  for(int i=1;i<n;i++)V.at(i)= (s.at(i)==s.at(i-1));//他は、左と同じかどうかを記録
  
  if(n==1){
    print(s=="x");
    return 0;
  }
  
  //1回目にRを選択した時
  string ANS="R";
  V.at(0)=!V.at(0);
  for(int i=1;i<n;i++){
    if(V.at(i)){//左と同じなので、Lを選択
      if(i+1!=n)V.at(i+1)=!V.at(i+1);
      V.at(0)=!V.at(0);
      ANS.push_back('L');
    }else{//左と違うので、Rを選択
      V.at(i)=!V.at(i);
      ANS.push_back('R');
    }
  }//for i end
  if(V.at(0)){
    cout<<"Yes"<<endl<<ANS<<endl;
    return 0;
  }
  
  V.at(0)= (s.at(0)=='o');//一番左だけは、実際に点灯しているかを記録
  for(int i=1;i<n;i++)V.at(i)= (s.at(i)==s.at(i-1));//他は、左と同じかどうかを記録
  //1回目にLを選択した時
  ANS="L";
  V.at(0)=!V.at(0);
  V.at(1)=!V.at(1);
  for(int i=1;i<n;i++){
    if(V.at(i)){//左と同じなので、Lを選択
      if(i+1!=n)V.at(i+1)=!V.at(i+1);
      V.at(0)=!V.at(0);
      ANS.push_back('L');
    }else{//左と違うので、Rを選択
      V.at(i)=!V.at(i);
      ANS.push_back('R');
    }
  }//for i end
  if(V.at(0)){
    cout<<"Yes"<<endl<<ANS<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}
0