Submission #1115355


Source Code Expand

#pragma region Template
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <stack>
#include <set>
#include <algorithm>
#include <bitset>
#include <functional>
#include <ctime>
#include <cassert>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <complex>
#pragma comment(linker, "/STACK:167772160")

using namespace std;
#define mp make_pair
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define print_var(x) cerr << #x << " : " << (x) << endl
#define print_array(arr, len) {cerr << #arr << " : "; for(int i = 0; i < len; ++i) cerr << arr[i] << ' '; cerr << endl;}
#define print_2d_array(arr, len1, len2) {cerr << #arr << endl; for(int i = 0; i < len1; ++i, cerr << endl) for(int j = 0; j < len2; ++j) cerr << arr[i][j] << ' ';}
#define print_iterable(i) {cerr << #i << " : "; for(auto e : i) cerr << e << ' '; cerr << endl;}
#define print_new_line() cerr << endl
#else
#define eprintf(...) (void)0
#define print_var(x) (void)0
#define print_array(arr, len) {}
#define print_2d_array(arr, len1, len2) {}
#define print_iterable(i) {}
#define print_new_line() (void)0
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int INF = 1e9 + 10;
const ll LINF = ll(2e18) + 10;
const double PI = acosl(-1);
const double eps = 1e-8;
const ld EPS = 1e-11;
#pragma endregion

const int N = 1e5 + 10;
char s[N], t[N];
int n;
char an[256];

bool check()
{
	for (int i = 1; i < n; ++i)
		if (t[i] == 'S' && s[i] == 'o' || t[i] == 'W' && s[i] == 'x')
			t[i + 1] = t[i - 1];
		else
			t[i + 1] = an[t[i - 1]];
	if (t[n] != t[0])
		return false;
	t[n] = 0;
	return true;
}

void solve()
{
	scanf("%d%s", &n, s);
	an['S'] = 'W';
	an['W'] = 'S';
	for(auto c1 : {'W', 'S'})
		for(auto c2 : {'W', 'S'})
		{
			t[0] = c1;
			t[1] = c2;
			if (check())
			{
				puts(t);
				return;
			}
		}
	puts("-1");
}

int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#ifdef NOERR
	freopen("err.txt", "w", stderr);
#endif
#else
	//freopen("alter.in", "r", stdin);
	//freopen("alter.out", "w", stdout);
#endif

#ifdef ST
	while(true)
		solve();
#endif
#ifdef CASES
#define MULTITEST
#endif
#ifdef MULTITEST
	int t;
	scanf("%d", &t);
	for (int i = 0; i < t; ++i)
	{
#ifdef CASES
		printf("Case #%d: ", i + 1);
#endif
		solve();
#ifdef CASES
		//eprintf("Passed case #%d:\n", i + 1);
#endif
	}
#else
		solve();
#endif

	eprintf("\n\nTime: %.3lf", double(clock()) / CLOCKS_PER_SEC);
}

Submission Info

Submission Time
Task D - Menagerie
User tinsane
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2907 Byte
Status WA
Exec Time 3 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:80:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%s", &n, s);
                      ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
WA × 1
AC × 10
WA × 6
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 WA 1 ms 256 KB
01.txt AC 2 ms 384 KB
02.txt AC 2 ms 384 KB
03.txt AC 1 ms 256 KB
04.txt WA 1 ms 256 KB
05.txt AC 2 ms 512 KB
06.txt WA 2 ms 512 KB
07.txt AC 1 ms 256 KB
08.txt WA 1 ms 256 KB
09.txt WA 1 ms 256 KB
10.txt WA 1 ms 256 KB
11.txt AC 2 ms 512 KB
12.txt AC 2 ms 512 KB
13.txt AC 3 ms 512 KB