Submission #1482505
Source Code Expand
#include <iostream> #include <queue> #include <vector> #include <cmath> #include <algorithm> #include <map> using namespace std; using ll = long long; const ll INF = 1e9; int N; string P; vector<char> T(100001); char inv(char s) { return s == 'S' ? 'W' : 'S'; } bool execute(char one, char two) { bool succ; T[0] = one; T[1] = two; for (int i = 1; i < N - 1; i++) { if (T[i] == 'S') { if (P[i] == 'o') { T[i+1] = T[i-1]; } else { T[i+1] = inv(T[i-1]); } } else { if (P[i] == 'o') { T[i+1] = inv(T[i-1]); } else { T[i+1] = T[i-1]; } } } if (T[0] == 'S') { if (P[0] == 'o' && T[N-1] != T[1]) return false; if (P[0] == 'x' && T[N-1] == T[1]) return false; } else { if (P[0] == 'x' && T[N-1] != T[1]) return false; if (P[0] == 'o' && T[N-1] == T[1]) return false; } if (T[N-1] == 'S') { if (P[N-1] == 'o') { succ = T[N-2] == T[0]; } else { succ = T[N-2] != T[0]; } } else { if (P[N-1] == 'o') { succ = T[N-2] != T[0]; } else { succ = T[N-2] == T[0]; } } return succ; } int main() { cin >> N >> P; if (execute('S', 'S') || execute('S', 'W') || execute('W', 'S') || execute('W', 'W')) { for(int i = 0; i < N; i++) cout << T[i]; cout << endl; } else { cout << -1 << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | sei0o |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1645 Byte |
Status | AC |
Exec Time | 10 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 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 | 1 ms | 384 KB |
00_example_02.txt | AC | 1 ms | 384 KB |
00_example_03.txt | AC | 1 ms | 384 KB |
01.txt | AC | 6 ms | 512 KB |
02.txt | AC | 4 ms | 512 KB |
03.txt | AC | 1 ms | 384 KB |
04.txt | AC | 1 ms | 384 KB |
05.txt | AC | 8 ms | 640 KB |
06.txt | AC | 7 ms | 640 KB |
07.txt | AC | 2 ms | 384 KB |
08.txt | AC | 2 ms | 384 KB |
09.txt | AC | 1 ms | 384 KB |
10.txt | AC | 2 ms | 384 KB |
11.txt | AC | 10 ms | 640 KB |
12.txt | AC | 10 ms | 640 KB |
13.txt | AC | 9 ms | 640 KB |