結果
| 問題 | No.3779 L or R |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-30 21:30:18 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 8 ms / 2,000 ms |
| + 117µs | |
| コード長 | 1,425 bytes |
| 記録 | |
| コンパイル時間 | 1,593 ms |
| コンパイル使用メモリ | 222,916 KB |
| 実行使用メモリ | 9,920 KB |
| 最終ジャッジ日時 | 2026-10-30 21:30:23 |
| 合計ジャッジ時間 | 4,693 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
string s; cin >> s;
{
string t = "";
t += 'L';
for(int i=1; i<N; i++){
if(s.at(i) == s.at(i-1)) t += t.back()^'L'^'R';
else t += t.back();
}
int l = 0,r = 0;
string S = "";
for(auto c : t) r += c=='L';
int pos = 0;
for(auto c : t){
if(c == 'R') l++;
if((r+l)%2) S += s.at(pos)^'o'^'x';
else S += s.at(pos);
pos++;
if(c == 'L') r--;
}
bool ok = true;
for(auto c : S) if(c == 'x') ok = false;
if(ok){cout << "Yes\n" << t << "\n"; return 0;}
}
{
string t = "";
t += 'R';
for(int i=1; i<N; i++){
if(s.at(i) == s.at(i-1)) t += t.back()^'L'^'R';
else t += t.back();
}
int l = 0,r = 0;
string S = "";
for(auto c : t) r += c=='L';
int pos = 0;
for(auto c : t){
if(c == 'R') l++;
if((r+l)%2) S += s.at(pos)^'o'^'x';
else S += s.at(pos);
pos++;
if(c == 'L') r--;
}
bool ok = true;
for(auto c : S) if(c == 'x') ok = false;
if(ok){cout << "Yes\n" << t << "\n"; return 0;}
}
cout << "No\n";
}