Submission #2402439
Source Code Expand
#include<iostream> #include<string> int N; int ans[100010]; std::string s; bool solve(int a,int b) { ans[0] = a; ans[1] = b; for (int i = 1; i < N; i++) { if (s[i] == 'o') { if (ans[i] == 1)ans[i + 1] = ans[i - 1]; else ans[i + 1] = -ans[i - 1]; } else { if (ans[i] == -1)ans[i + 1] = ans[i - 1]; else ans[i + 1] = -ans[i - 1]; } } return ans[0] == ans[N]; } void out() { for (int i = 0; i < N; i++) { std::cout << (ans[i] == 1 ? 'S' : 'W'); } std::cout << std::endl; } int main() { std::cin >> N >> s; if (solve(1, 1)) { out(); return 0; } if (solve(-1, 1)) { out(); return 0; }if (solve(1, -1)) { out(); return 0; }if (solve(-1, -1)) { out(); return 0; } std::cout << -1 << std::endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | ikefumy |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 799 Byte |
Status | WA |
Exec Time | 9 ms |
Memory | 896 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 | 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 | 6 ms | 640 KB |
02.txt | AC | 4 ms | 640 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 8 ms | 896 KB |
06.txt | AC | 7 ms | 896 KB |
07.txt | WA | 2 ms | 384 KB |
08.txt | WA | 2 ms | 384 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | WA | 2 ms | 384 KB |
11.txt | WA | 8 ms | 896 KB |
12.txt | WA | 8 ms | 896 KB |
13.txt | AC | 9 ms | 896 KB |