Submission #1981323
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; string s, ans = "-1"; char rev(char c) { return c == 'S' ? 'W' : 'S'; } void f(string t) { string w = s; w[0] = t[0]; w[1] = t[1]; for (int i = 1; i < n - 1; i++) { if (w[i] == 'S') { if (s[i] == 'o') w[i + 1] = w[i - 1]; else w[i + 1] = rev(w[i - 1]); } else { if (s[i] == 'o') w[i + 1] = rev(w[i - 1]); else w[i + 1] = w[i - 1]; } } bool ok = true; for (int i = 0; i < n; i++) { int l = (i - 1 + n) % n, r = (i + 1) % n; if (w[i] == 'S') { if (s[i] == 'o' && w[l] != w[r]) ok = false; if (s[i] == 'x' && w[l] == w[r]) ok = false; } else { if (s[i] == 'o' && w[l] == w[r]) ok = false; if (s[i] == 'x' && w[l] != w[r]) ok = false; } } if (ok) ans = w; } int main() { cin >> n >> s; f("SS"); f("SW"); f("WS"); f("WW"); cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | legosuke |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 995 Byte |
Status | AC |
Exec Time | 13 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 | 9 ms | 512 KB |
02.txt | AC | 7 ms | 512 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 12 ms | 640 KB |
06.txt | AC | 12 ms | 640 KB |
07.txt | AC | 3 ms | 256 KB |
08.txt | AC | 3 ms | 384 KB |
09.txt | AC | 2 ms | 256 KB |
10.txt | AC | 4 ms | 256 KB |
11.txt | AC | 13 ms | 640 KB |
12.txt | AC | 13 ms | 640 KB |
13.txt | AC | 13 ms | 640 KB |