Submission #1870988
Source Code Expand
#include <algorithm> #include <cctype> #include <complex> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using std::cin; using std::cout; using std::endl; using std::string; using std::to_string; using std::vector; using std::set; using std::queue; using std::priority_queue; using std::min; using std::max; using std::sort; using std::abs; char flip_animal(char c){ return c == 'S' ? 'W' : 'S'; } char flip_question(char c){ return c == 'o' ? 'x' : 'o'; } string solve(int n, const string& q, char a0, char a1) { string a(n, '?'); a[0] = a0; a[1] = a1; for(int i = 1; i < n - 1; i++){ char flip = a[i] == 'S' ? q[i] : flip_question(q[i]); a[i+1] = flip == 'o' ? a[i-1] : flip_animal(a[i-1]); } char flip = a[n-1] == 'S' ? q[n-1] : flip_question(q[n-1]); char next = flip == 'o' ? a[n-2] : flip_animal(a[n-2]); return next == a[0] ? a : ""; } int main(void) { int n; cin >> n; string q; cin >> q; string a; a = solve(n, q, 'S', 'S'); if(!a.empty()){ cout << a << endl; return 0; } a = solve(n, q, 'S', 'W'); if(!a.empty()){ cout << a << endl; return 0; } a = solve(n, q, 'W', 'S'); if(!a.empty()){ cout << a << endl; return 0; } a = solve(n, q, 'W', 'W'); if(!a.empty()){ cout << a << endl; return 0; } cout << -1 << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | somq14 |
Language | C++14 (Clang 3.8.0) |
Score | 0 |
Code Size | 1580 Byte |
Status | WA |
Exec Time | 8 ms |
Memory | 888 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 7 ms | 888 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
00_example_03.txt | AC | 1 ms | 256 KB |
01.txt | WA | 6 ms | 512 KB |
02.txt | AC | 4 ms | 384 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | WA | 7 ms | 640 KB |
06.txt | AC | 6 ms | 640 KB |
07.txt | WA | 2 ms | 384 KB |
08.txt | AC | 2 ms | 384 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | WA | 2 ms | 384 KB |
11.txt | WA | 7 ms | 704 KB |
12.txt | WA | 7 ms | 704 KB |
13.txt | WA | 8 ms | 704 KB |