Submission #1368493


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100;

int N; char S[MAX_N]; int Nr[MAX_N];

int main() {
	cin >> N; scanf("%s", S);
	for(int s=0; s<4; s++) {
		Nr[0] = s/2; Nr[1] = s%2;
		for(int i=2; i<N; i++) {
			int sum = Nr[i-2] + Nr[i-1];
			if(S[i-1] == 'o') Nr[i] = sum % 2;
			else Nr[i] = 1 - sum%2;
		}
		int f = (Nr[0] + Nr[1] + Nr[N-1]) % 2;
		int l = (Nr[N-2] + Nr[N-1] + Nr[0]) % 2;
		char test[5] = "ox";

		if(test[f] == S[0] && test[l] == S[N-1]) {
			for(int i=0; i<N; i++) printf("%c", Nr[i]==0?'S':'W');
			puts("");
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User kajebiii
Language C++14 (GCC 5.4.1)
Score 500
Code Size 970 Byte
Status AC
Exec Time 4 ms
Memory 768 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  cin >> N; scanf("%s", S);
                          ^

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 KB
00_example_02.txt AC 1 ms 256 KB
00_example_03.txt AC 1 ms 256 KB
01.txt AC 3 ms 640 KB
02.txt AC 2 ms 512 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 4 ms 768 KB
06.txt AC 3 ms 768 KB
07.txt AC 2 ms 384 KB
08.txt AC 2 ms 384 KB
09.txt AC 1 ms 256 KB
10.txt AC 2 ms 384 KB
11.txt AC 4 ms 768 KB
12.txt AC 4 ms 768 KB
13.txt AC 4 ms 768 KB