Submission #2694055
Source Code Expand
#include <iostream> #include <string> using namespace std; int n; char s[100001] = {}, a[100001] = {}; // a -> animals; s -> answers string ans; bool solve(char x, char y){ a[1] = x; a[2] = y; for(int i = 2; i <= n-1; i++) a[i] == 'S'? s[i] == 'o' ? a[i+1] = a[i-1] : a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S' : s[i] == 'x' ? a[i+1] = a[i-1] : a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S'; return a[n] == 'S' ? s[n] == 'o' ? a[n-1] == a[1] ? true : false : a[n-1] != a[1] ? true : false : // a[n] == 'W' s[n] == 'o' ? a[n-1] == a[1] ? false : true : a[n-1] != a[1] ? false : true ; } int main() { cin >> n; for(int h = 1; h <= n; h++) a[h] = '_'; for(int i = 1; i <= n; i++){ cin >> s[i]; } if(solve('S', 'S')){ for(int k = 1; k <= n; k++) cout << a[k]; cout << endl; } else if(solve('S', 'W')){ for(int k = 1; k <= n; k++) cout << a[k]; cout << endl; } else if(solve('W', 'S')){ for(int k = 1; k <= n; k++) cout << a[k]; cout << endl; } else if(solve('W', 'W')){ for(int k = 1; k <= n; k++) cout << a[k]; cout << endl; } else cout << "-1" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | DuckAndChips |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1187 Byte |
Status | WA |
Exec Time | 11 ms |
Memory | 512 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 | WA | 7 ms | 384 KB |
02.txt | AC | 5 ms | 384 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | WA | 10 ms | 512 KB |
06.txt | AC | 9 ms | 512 KB |
07.txt | WA | 3 ms | 256 KB |
08.txt | AC | 3 ms | 256 KB |
09.txt | AC | 2 ms | 256 KB |
10.txt | WA | 3 ms | 256 KB |
11.txt | WA | 10 ms | 512 KB |
12.txt | WA | 10 ms | 512 KB |
13.txt | WA | 11 ms | 512 KB |