Submission #1117506
Source Code Expand
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int MaxN = 1e5;
int n, c[MaxN + 5];
char s[MaxN + 5];
bool Solve()
{
int p1[5] = {0, 0, 0, 1, 1}, p2[5] = {0, 0, 1, 1, 0};
for(int j = 1; j <= 4; j++)
{
c[1] = p1[j]; c[2] = p2[j];
for(int i = 2; i <= n; i++)
{
if(s[i] == 'o')
{
if(c[i] == 0) c[i + 1] = c[i - 1];
else c[i + 1] = 1 - c[i - 1];
}
if(s[i] == 'x')
{
if(c[i] == 0) c[i + 1] = 1 - c[i - 1];
else c[i + 1] = c[i - 1];
}
}
if(c[n + 1] == c[1])
{
if(s[1] == 'o')
{
if(c[1] == 0 && c[n] == c[2]) return 1;
if(c[1] == 1 && c[n] != c[2]) return 1;
}
else
{
if(c[1] == 0 && c[n] != c[2]) return 1;
if(c[1] == 1 && c[n] == c[2]) return 1;
}
}
}
return 0;
}
int main()
{
scanf("%d", &n);
getchar();
scanf("%s", s + 1);
bool ok = Solve();
if(!ok) printf("-1\n");
else
{
for(int i = 1; i <= n; i++)
if(c[i] == 0) printf("s");
else printf("w");
printf("\n");
}
}
Submission Info
Submission Time
2017-02-18 21:53:37+0900
Task
D - Menagerie
User
chenjiaqi
Language
C++14 (GCC 5.4.1)
Score
0
Code Size
1236 Byte
Status
WA
Exec Time
5 ms
Memory
768 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:56:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:58:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", s + 1);
^
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
WA
1 ms
256 KB
00_example_02.txt
AC
1 ms
256 KB
00_example_03.txt
WA
1 ms
256 KB
01.txt
WA
4 ms
640 KB
02.txt
WA
2 ms
512 KB
03.txt
AC
1 ms
256 KB
04.txt
WA
1 ms
256 KB
05.txt
WA
5 ms
768 KB
06.txt
WA
4 ms
768 KB
07.txt
WA
2 ms
384 KB
08.txt
WA
2 ms
384 KB
09.txt
WA
1 ms
256 KB
10.txt
AC
2 ms
384 KB
11.txt
WA
5 ms
768 KB
12.txt
WA
5 ms
768 KB
13.txt
WA
5 ms
768 KB