Submission #1177092
Source Code Expand
#include <stdio.h>
#include <stdlib.h>
int judge(int i, int n, char *s, char *t, char animal) {
if (i == n) {
if ((t[i - 1] == 'S' && s[i - 1] == 'o') || (t[i - 1] == 'W' && s[i - 1] == 'x')) {
if (t[i - 2] == t[0])
return 0;
else
return -1;
} else {
if (t[i - 2] != t[0])
return 0;
else
return -1;
}
}
t[i] = animal;
if ((t[i] == 'S' && s[i] == 'o') || (t[i] =='W' && s[i] == 'x'))
return judge(i + 1, n, s, t, t[i - 1]);
else {
if (t[i - 1] == 'S')
return judge(i + 1, n, s, t, 'W');
else
return judge(i + 1, n, s, t, 'S');
}
}
int main() {
long int n;
char *s, *t;
scanf("%ld\n", &n);
s = (char *)malloc(sizeof(char) * (n + 1));
t = (char *)malloc(sizeof(char) * (n + 1));
scanf("%s", s);
t[n] = '\0';
t[0] = 'S';
if (judge(1, n, s, t, 'S') == 0)
printf("%s\n", t);
else if (judge(1, n, s, t, 'W') == 0)
printf("%s\n", t);
else {
t[0] = 'W';
if (judge(1, n, s, t, 'S') == 0)
printf("%s\n", t);
else if (judge(1, n, s, t, 'W') == 0)
printf("%s\n", t);
else
printf("-1\n");
}
free(s);
free(t);
return 0;
}
Submission Info
Submission Time
2017-03-23 11:55:57+0900
Task
D - Menagerie
User
koendango
Language
C (GCC 5.4.1)
Score
0
Code Size
1221 Byte
Status
WA
Exec Time
2 ms
Memory
512 KB
Compile Error
./Main.c: In function ‘main’:
./Main.c:35:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%ld\n", &n);
^
./Main.c:38:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", s);
^
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
AC
1 ms
128 KB
00_example_02.txt
AC
1 ms
128 KB
00_example_03.txt
AC
1 ms
128 KB
01.txt
WA
2 ms
384 KB
02.txt
AC
1 ms
256 KB
03.txt
AC
1 ms
128 KB
04.txt
AC
1 ms
128 KB
05.txt
WA
2 ms
384 KB
06.txt
AC
1 ms
384 KB
07.txt
WA
1 ms
256 KB
08.txt
AC
1 ms
256 KB
09.txt
AC
1 ms
128 KB
10.txt
WA
1 ms
256 KB
11.txt
WA
2 ms
512 KB
12.txt
WA
2 ms
512 KB
13.txt
WA
2 ms
512 KB