結果
| 問題 | No.3779 L or R |
| コンテスト | |
| ユーザー |
7deQSJCy8c4Hg7I
|
| 提出日時 | 2026-11-13 13:48:39 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 8 ms / 2,000 ms |
| + 976µs | |
| コード長 | 8,003 bytes |
| 記録 | |
| コンパイル時間 | 5,499 ms |
| コンパイル使用メモリ | 417,324 KB |
| 実行使用メモリ | 8,704 KB |
| 最終ジャッジ日時 | 2026-11-13 13:48:48 |
| 合計ジャッジ時間 | 9,204 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#if __INCLUDE_LEVEL__ == 0
#include __BASE_FILE__
void solve() {
ll N, M, K, a = 0, b = 0, c = 0;
string S = "", T = "";
ll t;
cin >> N;
cin >> S;
if (N == 1) {
Yes(S[0] == 'x');
if (S[0] == 'x') {
cout << "L" << '\n';
}
return;
}
// Yes(1);
vll X(N);
X[0] = (S[0] == 'x');
rep(i, N - 1) { X[i + 1] = (S[i] != S[i + 1]); }
rep(i, 2) {
vll nX = X;
T.clear();
if (i == 0) {
T.push_back('L');
nX[1] ^= 1;
} else
T.push_back('R');
nX[0] ^= 1;
reps(j, 1, N) {
if (nX[j] == 1) {
T.push_back('R');
nX[j] ^= 1;
} else {
T.push_back('L');
nX[0] ^= 1;
if (j != N - 1) {
nX[j + 1] ^= 1;
}
}
}
if (nX == vll(N, 0)) {
Yes(1);
cout << T << '\n';
return;
}
}
Yes(0);
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << std::fixed << std::setprecision(20);
int t = 1;
// cin >> t;
rep(_, t) solve();
}
#elif __INCLUDE_LEVEL__ == 2
#elif __INCLUDE_LEVEL__ == 1
#pragma once
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int> >;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvvvll = vector<vvvll>;
using vvvvvll = vector<vvvvll>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vld = vector<long double>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using pii = pair<long long, long long>;
using mint = modint1000000007;
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); i++)
#define rep(i, n) for (ll i = (0); i < (ll)(n); i++)
#define rrep(i, n) for (ll i = (1); i < (ll)(n + 1); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define rrepd(i, n) for (ll i = n; i >= 1; i--)
#define ALL(n) n.begin(), n.end()
#define rALL(n) n.rbegin(), n.rend()
#define fore(i, a) for (auto& i : a)
#define IN(a, x, b) (a <= x && x < b)
#define IN(a, x, b) (a <= x && x < b)
#define INIT \
std::ios::sync_with_stdio(false); \
std::cin.tie(0);
#pragma once
template <typename T>
// [0,M)についての階上を求める
vector<T> KAI(int M) {
vector<T> kai(M, 1);
rep(i, M - 1) { kai[i + 1] = kai[i] * (i + 1); }
return kai;
}
template <typename T>
vector<T> DIV(int M) {
vector<T> kai = KAI<T>(M), div(M, 1);
div.back() /= kai.back();
for (int i = M - 2; i >= 0; --i) {
div[i] = div[i + 1] * (i + 1);
}
return div;
}
long long Power(long long a, long long b, long long m) {
long long p = a, Answer = 1;
p %= m;
while (b > 0) {
if (b & 1) {
Answer *= p;
Answer %= m;
}
p = (p * p) % m;
b /= 2;
}
return Answer;
}
// a ÷ b を m で割った余りを返す関数え
long long Division(long long a, long long b, long long m) {
return (a * Power(b, m - 2, m)) % m;
}
template <class T>
void output(T& W, bool x) {
cout << W;
if (!x)
cout << ' ';
else
cout << endl;
return;
}
// sは改行するか否かを表す
template <class T>
void output(vector<T>& W, bool s) {
rep(i, W.size()) { output(W[i], ((i == W.size() - 1) || s)); }
return;
}
// sは改行するか否かを表す
template <class T>
void output(vector<vector<T> >& W, bool s) {
rep(i, W.size()) { output(W[i], s); }
return;
}
template <class T>
T vectorsum(vector<T>& W, int a, int b) {
return accumulate(W.begin() + a, W.end() + b, (T)0);
}
template <class T>
T vectorsum(vector<T>& W) {
int b = W.size();
return accumulate(ALL(W), (T)0);
}
template <class T>
inline T CHMAX(T& a, const T b) {
return a = (a < b) ? b : a;
}
template <class T>
inline T CHMIN(T& a, const T b) {
return a = (a > b) ? b : a;
}
template <class T>
void input(T& W) {
cin >> W;
return;
}
template <class T>
void input(vector<T>& W) {
for (auto& u : W) input(u);
return;
}
template <class T, class TT>
void add(T& W, TT& a) {
W += a;
return;
}
template <class T>
void add(vector<T>& W, vector<T>& a) {
rep(i, W.size()) add(W[i], a[i]);
}
template <class T>
void add(T& W, T& a) {
W += a;
}
template <class T, class TT>
void add(vector<T>& W, TT a) {
for (auto& u : W) add(u, a);
return;
}
vll dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
void Yes(bool b) {
if (b)
cout << "Yes" << '\n';
else
cout << "No" << '\n';
}
struct TRI {
ll a;
ll b;
ll c;
ll d;
};
bool operator>(const TRI& r, const TRI& l) {
return (r.a > l.a || (r.a == l.a && r.b > l.b) ||
(r.a == l.a && r.b == l.b && r.c > l.c));
}
bool operator<(const TRI& r, const TRI& l) {
return (r.a < l.a || (r.a == l.a && r.b < l.b) ||
(r.a == l.a && r.b == l.b && r.c < l.c));
}
struct TRK {
ll a;
ll b;
ll c;
};
bool operator>(const TRK& r, const TRK& l) {
return (r.a > l.a || (r.a == l.a && r.b > l.b) ||
(r.a == l.a && r.b == l.b && r.c > l.c));
}
bool operator<(const TRK& r, const TRK& l) {
return (r.a < l.a || (r.a == l.a && r.b < l.b) ||
(r.a == l.a && r.b == l.b && r.c < l.c));
}
std::random_device rnd;
std::mt19937 mt(rnd());
default_random_engine engineX(rnd());
// 平均0.0、標準偏差1.0で分布させる
std::normal_distribution<> seikidist(0.0, 1.0);
template <class T>
// 0以上K未満の整数を等確率で発生させる
long long randomX(T K) {
uniform_int_distribution<ll> select(0, K - 1);
return select(mt);
}
template <typename T>
vector<T> dycstra(vector<vector<pair<ll, T> > > G, ll N, ll K) {
vb kaku(N, false);
vector<T> cur(N, 1e18);
cur[K] = 0;
priority_queue<pair<T, ll>, vector<pair<T, ll> >, greater<pair<T, ll> > > Q;
Q.push(make_pair(cur[K], K));
while (!Q.empty()) {
ll pos = Q.top().second;
Q.pop();
if (kaku[pos]) continue;
kaku[pos] = true;
for (ll i = 0; i < G[pos].size(); i++) {
ll nex = G[pos][i].first;
T cost = G[pos][i].second;
if (cur[nex] > cur[pos] + cost) {
cur[nex] = cur[pos] + cost;
Q.push(make_pair(cur[nex], nex));
}
}
}
return cur;
}
__int128_t Power(__int128_t a, __int128_t b, __int128_t m) {
__int128_t p = a, Answer = 1;
for (int i = 0; i < 63; i++) {
__int128_t wari = (1LL << i);
if ((b / wari) % 2 == 1) {
Answer %= m;
Answer = (Answer * p) % m; // 「a の 2^i 乗」が掛けられるとき
}
p %= m;
p = (p * p) % m;
}
return Answer;
}
// ミラーラビン素数判定法(10**18以下の素数までなら判定可能)
bool is_prime(long long N) {
if (N <= 1) return false;
if (N == 2 || N == 3) return true;
if (N % 2 == 0) return false;
vector<long long> A = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};
long long s = 0, d = N - 1;
while (d % 2 == 0) {
++s;
d >>= 1;
}
for (auto a : A) {
if (a % N == 0) return true;
long long t, x = Power(a, d, N);
if (x != 1) {
for (t = 0; t < s; ++t) {
if (x == N - 1) break;
x = __int128_t(x) * x % N;
}
if (t == s) return false;
}
}
return true;
}
#endif
7deQSJCy8c4Hg7I