Submission #3435512
Source Code Expand
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define for1(i, n) for (int i = 1; i <= (int)n; ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long i64;
typedef vector<int> vi;
typedef vector<i64> vi64;
typedef vector<vi> vvi;
typedef vector<vi64> vvi64;
typedef double ld;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout << fixed;
int N;
string s;
cin >> N >> s;
vi vs(N, 0);
forn(i, N) {
if (s[i] == 'x') vs[i] = 1;
}
vi _vs(N, 0);
string ans(N, 'S');
forn(i, N) {
if (vs[i] != _vs[i]) {
ans[(i + 1) % N] = 'W';
fore(j, i, i + 2) {
_vs[j % N] ^= 1;
}
}
}
bool isans = true;
forn(i, N) {
if (vs[i] != _vs[i]) {
isans = false;
break;
}
}
if (isans) {
cout << ans << endl;
return 0;
}
_vs = vi(N, 0);
ans = string(N, 'S');
fore(i, 1, N) {
if (vs[i] != _vs[i]) {
ans[(i + 1) % N] = 'W';
fore(j, i, i + 2) {
_vs[j % N] ^= 1;
}
}
}
isans = true;
forn(i, N) {
if (vs[i] != _vs[i]) {
isans = false;
break;
}
}
if (isans) {
cout << ans << endl;
return 0;
}
_vs = vi(N, 0);
ans = string(N, 'S');
fore(i, 2, N + 1) {
if (vs[i] != _vs[i]) {
ans[(i + 1) % N] = 'W';
fore(j, i, i + 2) {
_vs[j % N] ^= 1;
}
}
}
isans = true;
forn(i, N) {
if (vs[i] != _vs[i]) {
isans = false;
break;
}
}
if (isans) {
cout << ans << endl;
return 0;
}
_vs = vi(N, 0);
ans = string(N, 'S');
fore(i, 3, N + 2) {
if (vs[i] != _vs[i]) {
ans[(i + 1) % N] = 'W';
fore(j, i, i + 2) {
_vs[j % N] ^= 1;
}
}
}
isans = true;
forn(i, N) {
if (vs[i] != _vs[i]) {
isans = false;
break;
}
}
if (isans) {
cout << ans << endl;
return 0;
}
// for (auto c: vs) cout << c; cout << endl;
// for (auto c: _vs) cout << c; cout << endl;
cout << -1 << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Menagerie |
User |
kazuhitot |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2798 Byte |
Status |
WA |
Exec Time |
8 ms |
Memory |
1736 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 |
6 ms |
1288 KB |
02.txt |
AC |
2 ms |
768 KB |
03.txt |
AC |
1 ms |
256 KB |
04.txt |
WA |
1 ms |
256 KB |
05.txt |
WA |
7 ms |
1720 KB |
06.txt |
AC |
3 ms |
1280 KB |
07.txt |
WA |
2 ms |
512 KB |
08.txt |
AC |
2 ms |
512 KB |
09.txt |
AC |
1 ms |
384 KB |
10.txt |
AC |
2 ms |
512 KB |
11.txt |
WA |
8 ms |
1736 KB |
12.txt |
WA |
8 ms |
1736 KB |
13.txt |
WA |
8 ms |
1736 KB |