結果
| 問題 | No.3779 L or R |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-30 22:06:14 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 2,944 bytes |
| 記録 | |
| コンパイル時間 | 846 ms |
| コンパイル使用メモリ | 145,236 KB |
| 実行使用メモリ | 9,932 KB |
| 最終ジャッジ日時 | 2026-10-30 22:06:19 |
| 合計ジャッジ時間 | 4,690 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge7_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 18 WA * 22 |
ソースコード
//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);
ANS.push_back('L');
}else{//左と違うので、Rを選択
V.at(i)=!V.at(i);
V.at(0)=!V.at(0);
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);
ANS.push_back('L');
}else{//左と違うので、Rを選択
V.at(i)=!V.at(i);
V.at(0)=!V.at(0);
ANS.push_back('R');
}
}//for i end
if(V.at(0)){
cout<<"Yes"<<endl<<ANS<<endl;
return 0;
}
cout<<"No"<<endl;
return 0;
}