QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#355971 | #8287. Caught in the Middle | ckiseki# | WA | 0ms | 3600kb | C++20 | 1.7kb | 2024-03-17 14:19:45 | 2024-03-17 14:19:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(auto s, auto ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int f = 0;
(..., (cerr << (f++ ? ", " : "") << a));
cerr << ")\e[0m\n";
}
#include <experimental/iterator>
void orange_(auto s, auto L, auto R) {
cerr << "\e[1;33m[ " << s << " ] = [ ";
using namespace experimental;
copy(L, R, make_ostream_joiner(cerr, ", "));
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif
bool win(string s) {
static map<string, bool> cache;
if (auto it = cache.find(s); it != cache.end())
return it->second;
if (s.empty())
return false;
if (s[0] == 'L' or s.back() == 'R')
return true;
bool canwin = false;
for (size_t i = 0; i < s.size(); ++i) {
if (s[i] == 'L') {
canwin = not win(s.substr(0, i));
} else {
canwin = not win(s.substr(i + 1));
}
if (canwin)
break;
}
return cache[s] = canwin;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string s;
cin >> s;
bool valid = true;
int v = 0;
for (auto c : s) {
if (c == 'R')
v++;
else
v--;
if (v < 0)
valid = false;
}
cout << (valid ? "Bob" : "Alice") << '\n';
}
//queue<string> bfs;
//bfs.push("");
//for (int i = 0; i < 10000; ++i) {
// auto s = bfs.front();
// bfs.pop();
// if (not win(s))
// cout << "> " << s << '\n';
// bfs.push(s + "L");
// bfs.push(s + "R");
//}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3600kb
input:
20 10 RLRRRRLLRR 10 LRLLLLRRLR 6 RLRLRL 10 LLRLRRRRLR 6 LRRLLL 3 RLR 5 LLRRR 6 RRRRRL 9 LRRRLRRLR 1 R 10 RRRLLRRLLL 6 LRLLLR 9 LLRLRLRLR 7 RRRRLRR 2 LL 10 RRRLLRRLRR 2 RL 7 RRLRRLR 3 LLR 10 LLRLRRRLLR
output:
Bob Alice Bob Alice Alice Bob Alice Bob Alice Bob Bob Alice Alice Bob Alice Bob Bob Bob Alice Alice
result:
wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'