結果
| 問題 | No.3779 L or R |
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2026-10-30 21:26:37 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 5 ms / 2,000 ms |
| + 39µs | |
| コード長 | 1,352 bytes |
| 記録 | |
| コンパイル時間 | 2,826 ms |
| コンパイル使用メモリ | 363,516 KB |
| 実行使用メモリ | 9,844 KB |
| 最終ジャッジ日時 | 2026-10-30 21:26:44 |
| 合計ジャッジ時間 | 6,890 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
string s;
cin >> s;
string t(n, '.');
t[0] = 'L';
rep(i, n - 1) {
t[i+1] = s[i] == s[i+1] ? t[i] ^ 'L' ^ 'R' : t[i];
}
rep(_, 2) {
for (char& c : t) c ^= 'L' ^ 'R';
int left = count(all(t), 'L'), right = 0;
bool ok = true;
rep(i, n) {
if (t[i] == 'L') left--;
if (!((s[i] == 'o') ^ 1 ^ (left % 2) ^ (right % 2))) {
ok = false;
break;
}
if (t[i] == 'R') right++;
}
if (ok) {
cout << "Yes\n" << t << '\n';
return 0;
}
}
cout << "No\n";
}
Kude