Submission #1368650
Source Code Expand
#include <stdio.h> int main(void) { int N; char *s, *ans; int cnt_1 = 1, cnt_2 = 1, i, cnt_c = 0; scanf("%d", &N); s = (char*)malloc(sizeof(char)*(N + 1)); ans = (char*)malloc(sizeof(char)*(N + 2)); scanf("%s", s); while (cnt_c < 4) { if (cnt_1 == 1) { ans[0] = 'S'; if (cnt_2 == 1) { ans[1] = 'S'; cnt_2++; } else ans[1] = 'W'; } else { ans[0] = 'W'; if (cnt_2 == 1) { ans[1] = 'S'; cnt_2++; } else ans[1] = 'W'; } for (i = 2; i <= N; i++) { if (ans[i - 1] == 'S') { if (s[i - 1] == 'o') ans[i] = ans[i - 2]; else if (ans[i - 2] == 'S') ans[i] = 'W'; else ans[i] = 'S'; } else { if (s[i - 1] == 'x') ans[i] == ans[i - 2]; else if (ans[i - 2] == 'S') ans[i] = 'W'; else ans[i] = 'S'; } } if (ans[0] == ans[N]) break; else { for (i = 0; i <= N; i++) ans[i] = '0'; cnt_c++; } if ((cnt_1 == 1) && (cnt_2 != 1)) { cnt_1++; cnt_2 = 1; } } if (cnt_c == 4) printf("-1"); else for (i = 0; i < N; i++) printf("%c", ans[i]); printf("\n"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | woodline23xx |
Language | C (GCC 5.4.1) |
Score | 0 |
Code Size | 1126 Byte |
Status | WA |
Exec Time | 3 ms |
Memory | 512 KB |
Compile Error
./Main.c: In function ‘main’: ./Main.c:9:13: warning: implicit declaration of function ‘malloc’ [-Wimplicit-function-declaration] s = (char*)malloc(sizeof(char)*(N + 1)); ^ ./Main.c:9:13: warning: incompatible implicit declaration of built-in function ‘malloc’ ./Main.c:9:13: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’ ./Main.c:8:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.c:11:2: 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 | WA | 1 ms | 256 KB |
03.txt | WA | 1 ms | 128 KB |
04.txt | WA | 1 ms | 128 KB |
05.txt | WA | 3 ms | 384 KB |
06.txt | WA | 2 ms | 384 KB |
07.txt | WA | 1 ms | 256 KB |
08.txt | WA | 1 ms | 256 KB |
09.txt | WA | 1 ms | 128 KB |
10.txt | WA | 1 ms | 256 KB |
11.txt | WA | 2 ms | 512 KB |
12.txt | WA | 3 ms | 512 KB |
13.txt | WA | 2 ms | 512 KB |