Submission #1675558
Source Code Expand
#include <bits/stdc++.h> using namespace std; main() { int N; cin >> N; string s; cin >> s; s += s[0]; string init[4] = {"SS", "SW", "WS", "WW"}; string ans{}; for (int i = 0; i < 4; i++) { string res = init[i]; for (int j = 0; j < N - 1; j++) { if (res.substr(j, 2) == "SS") res += (s[j + 1] == 'o') ? 'S' : 'W'; if (res.substr(j, 2) == "SW") res += (s[j + 1] == 'o') ? 'W' : 'S'; if (res.substr(j, 2) == "WS") res += (s[j + 1] == 'o') ? 'W' : 'S'; if (res.substr(j, 2) == "WW") res += (s[j + 1] == 'o') ? 'S' : 'W'; } bool ok = false; if (res.back() != res.front()) continue; if (res.substr(N - 1, 2) == "SS") { if (s[0] == 'o' && res[1] == 'S' || s[0] == 'x' && res[1] == 'W') ok = true; } if (res.substr(N - 1, 2) == "SW") { if (s[0] == 'o' && res[1] == 'W' || s[0] == 'x' && res[1] == 'S') ok = true; } if (res.substr(N - 1, 2) == "WS") { if (s[0] == 'o' && res[1] == 'W' || s[0] == 'x' && res[1] == 'S') ok = true; } if (res.substr(N - 1, 2) == "WW") { if (s[0] == 'o' && res[1] == 'S' || s[0] == 'x' && res[1] == 'W') ok = true; } if (ok) ans = res.substr(0, N); } cout << ( (ans.empty()) ? "-1" : ans ) << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | hrbt |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1284 Byte |
Status | AC |
Exec Time | 172 ms |
Memory | 736 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 | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
00_example_03.txt | AC | 1 ms | 256 KB |
01.txt | AC | 66 ms | 640 KB |
02.txt | AC | 50 ms | 512 KB |
03.txt | AC | 4 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 94 ms | 684 KB |
06.txt | AC | 91 ms | 688 KB |
07.txt | AC | 30 ms | 384 KB |
08.txt | AC | 18 ms | 384 KB |
09.txt | AC | 9 ms | 256 KB |
10.txt | AC | 21 ms | 384 KB |
11.txt | AC | 104 ms | 736 KB |
12.txt | AC | 172 ms | 736 KB |
13.txt | AC | 104 ms | 688 KB |