Submission #1454410
Source Code Expand
#include <cstdio> #include <vector> #include <string> #include <stdlib.h> #include <iostream> using namespace std; int n; string str; string ans; void go() { for (int i = 1; i <= n - 2; i++) { char nxt; if (ans[i] == 'S') { if (str[i] == 'o') { nxt = ans[i - 1]; } else { nxt = (ans[i - 1] == 'S' ? 'W' : 'S'); } } else { if (str[i] == 'o') { nxt = (ans[i - 1] == 'S' ? 'W' : 'S'); } else { nxt = ans[i - 1]; } } if (i == n - 2) { if (ans[n-1] != nxt) { return; } } ans[i + 1] = nxt; } if (ans[n - 1] == 'S') { if (str[n - 1] == 'o' && ans[0] == ans[n - 2] || str[n - 1] == 'x' && ans[0] != ans[n - 2]) { cout << ans << endl; exit(0); } } else { if (str[n - 1] == 'x' && ans[0] == ans[n - 2] || str[n - 1] == 'o' && ans[0] != ans[n - 2]) { cout << ans << endl; exit(0); } } } int main() { cin >> n; ans.resize(n); cin >> str; //[0] = sheep if (str[0] == 'o') { ans[0] = 'S'; //양양 ans[n - 1] = ans[1] = 'S'; go(); //늑늑 ans[n - 1] = ans[1] = 'W'; go(); ans[0] = 'W'; ans[n - 1] = 'S'; ans[1] = 'W'; go(); ans[n - 1] = 'W'; ans[1] = 'S'; go(); } else { ans[0] = 'S'; ans[n - 1] = 'S'; ans[1] = 'W'; go(); ans[n - 1] = 'W'; ans[1] = 'S'; go(); ans[0] = 'W'; ans[n - 1] = ans[1] = 'S'; go(); ans[n - 1] = ans[1] = 'W'; go(); } puts("-1"); }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | petil777 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1467 Byte |
Status | AC |
Exec Time | 8 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 | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
00_example_03.txt | AC | 1 ms | 256 KB |
01.txt | AC | 5 ms | 512 KB |
02.txt | AC | 3 ms | 384 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 7 ms | 640 KB |
06.txt | AC | 5 ms | 640 KB |
07.txt | AC | 2 ms | 256 KB |
08.txt | AC | 2 ms | 384 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 2 ms | 256 KB |
11.txt | AC | 7 ms | 640 KB |
12.txt | AC | 7 ms | 640 KB |
13.txt | AC | 8 ms | 640 KB |