Submission #1118884


Source Code Expand

#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n;
char in[M],tmp[M];
bool check(int t1,int t2)
{
	tmp[1] = t1;
	tmp[2] = t2;
 
	REP(i,2,n-1)
	{
		if(in[i]=='o')
			tmp[i+1] = tmp[i-1] ^ (tmp[i]?0:1);
		else
			tmp[i+1] = tmp[i-1] ^ (tmp[i]?1:0);
	}
	
	//1
	bool ans = (tmp[n]==tmp[2]) == (in[1]=='o');
	if(tmp[1] != ans) return false;
 
	ans = (tmp[n-1]==tmp[1]) == (in[n]=='o');
	if(tmp[n]!=ans) return false;
	
	return true;
}
int main()
{
	bool flg;
	while(~scanf("%d",&n))
	{
		flg = false;
		scanf("%s", in+1);
 
		REP(i,0,1)
		{
			if(flg) break;

			REP(j,0,1) if( check(i,j) )
			{
				flg = true;
				break;
			}
		}
 
		if(!flg) puts("-1");
		else
		{
			REP(i,1,n) printf("%c", tmp[i]?'S':'W');
			puts("");
		}
	}
	return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User Nekosyndrome
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1249 Byte
Status AC
Exec Time 4 ms
Memory 512 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:50:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", in+1);
                    ^

Judge Result

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