Submission #1480198
Source Code Expand
#include <bits/stdc++.h> #define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i) #define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i) #define size(x) ((int) (x.size())) using namespace std; typedef long long llong; const llong inf = (llong) 1e+9 + 7ll; const llong linf = (llong) 1e+18 + 7ll; const long double eps = (long double) 1e-9; const long double pi = acosl((long double) -1.0); const int alph = 26; mt19937 mrand(random_device{} ()); template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; } template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; } static char buff[(int) 2e6 + 17]; // reads std::string const int maxn = (int) 2e5 + 17; int n; string s; bool read() { if (scanf("%d", &n) != 1) return false; scanf("%s", buff); s = buff; return true; } void solve() { vector<int> ans(n + 1); for (ans[0] = 0; ans[0] <= 1; ++ans[0]) for (ans[1] = 0; ans[1] <= 1; ++ans[1]) { for (int i = 1; i < n; ++i) { ans[i + 1] = ans[i] ^ ans[i - 1]; if (s[i] == 'x') ans[i + 1] ^= 1; } if (ans[n] == ans[0]) { bool good = true; forn (i, n) { int l = (i - 1 + n) % n; int r = (i + 1) % n; int cur = ans[l] ^ ans[r]; if (ans[i] == 1) cur ^= 1; good &= ((cur == 1 && s[i] == 'x') || (cur == 0 && s[i] == 'o')); } if (good) { forn (i, n) if (ans[i] == 1) printf("W"); else printf("S"); printf("\n"); return ; } } } printf("-1\n"); } int main() { #if SEREZHKA freopen("file.in", "r", stdin); #endif while (read()) solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | serezhae |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1794 Byte |
Status | AC |
Exec Time | 11 ms |
Memory | 896 KB |
Compile Error
./Main.cpp: In function ‘bool read()’: ./Main.cpp:32:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", buff); ^
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 | 2 ms | 512 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
00_example_03.txt | AC | 1 ms | 256 KB |
01.txt | AC | 7 ms | 640 KB |
02.txt | AC | 4 ms | 512 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 10 ms | 896 KB |
06.txt | AC | 6 ms | 896 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 | 4 ms | 384 KB |
11.txt | AC | 11 ms | 896 KB |
12.txt | AC | 11 ms | 896 KB |
13.txt | AC | 11 ms | 896 KB |