Submission #1117389


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

char str[100050];
int dp[100050];

int main() {
	int N;
	scanf("%d",&N);
	scanf("%s", str);
	int sl = N;
	int dx[] = {0, 1, 1, 0};
	int dy[] = {1, 0, 1, 0};
	for (int i = 0; i < 4; i++) {
		dp[0] = dx[i];
		dp[1] = dy[i];
		for (int j = 2; j < sl; j++) {
			if (str[j-1] == 'o') {
				if (dp[j-1] == 1) {
					dp[j] = dp[j-2];
				} else {
					dp[j] = 1 - dp[j-2];
				}
			} else {
				if (dp[j-1] == 1) {
					dp[j] = 1 - dp[j-2];
				} else {
					dp[j] = dp[j-2];
				}
			}
		}
		bool loob = false;
		if (dp[sl - 1] == 1) {
			if (str[sl-1] == 'o') {
				if (dp[sl - 2] == dp[0]) {
					loob = true;
				}
			} else {
				if (dp[sl - 2] != dp[0]) {
					loob = true;
				}
			}
		} else {
			if (str[sl - 1] == 'x') {
				if (dp[sl - 2] == dp[0]) {
					loob = true;
				}
			} else {
				if (dp[sl - 2] != dp[0]) {
					loob = true;
				}
			}
		}
		if (loob == true) {
			for (int j = 0; j < sl; j++) {
				if (dp[j] == 0) printf("W");
				else printf("S");
			}
			printf("\n");
			return 0;
		}
	}
	printf("-1");
}

Submission Info

Submission Time
Task D - Menagerie
User vlwk
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1138 Byte
Status WA
Exec Time 4 ms
Memory 768 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:9:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
                ^
./Main.cpp:10:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", str);
                  ^

Judge Result

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