Submission #1116782
Source Code Expand
#include <bits/stdc++.h> using namespace std; int i, n; string s, rs; map<char, char> M; string Solve(char start, char last) { string rs; while(rs.size() != s.size()) rs += " "; rs[0] = start; rs[n - 1] = last; for(i = 0; i < n - 1; ++i) if(s[i] == 'o') rs[(i + n + 1) % n] = (rs[i] == 'S' ? rs[(i + n - 1) % n] : M[rs[(i + n - 1) % n]]); else rs[(i + n + 1) % n] = (rs[i] == 'W' ? rs[(i - 1 + n) % n] : M[rs[(i + n - 1) % n]]); for(i = 0; i < n; ++i) { int st = (i + n - 1) % n; int dr = (i + n + 1) % n; if(rs[i] == 'S') { if(s[i] == 'o' && rs[st] != rs[dr]) return "-1"; if(s[i] == 'x' && rs[st] == rs[dr]) return "-1"; } else { if(s[i] == 'o' && rs[st] == rs[dr]) return "-1"; if(s[i] == 'x' && rs[st] != rs[dr]) return "-1"; } } return rs; } int main() { ios_base::sync_with_stdio(0); cin >> n >> s; M['S'] = 'W'; M['W'] = 'S'; rs = Solve('S', 'S'); if(rs != "-1") return cout << rs << '\n', 0; rs = Solve('S', 'W'); if(rs != "-1") return cout << rs << '\n', 0; rs = Solve('W', 'S'); if(rs != "-1") return cout << rs << '\n', 0; cout << Solve('W', 'W') << '\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | Djok |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1227 Byte |
Status | AC |
Exec Time | 13 ms |
Memory | 684 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 | 9 ms | 512 KB |
02.txt | AC | 3 ms | 512 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 12 ms | 684 KB |
06.txt | AC | 5 ms | 640 KB |
07.txt | AC | 3 ms | 384 KB |
08.txt | AC | 2 ms | 384 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 3 ms | 384 KB |
11.txt | AC | 11 ms | 648 KB |
12.txt | AC | 11 ms | 648 KB |
13.txt | AC | 13 ms | 676 KB |