Submission #1117248
Source Code Expand
#include<stdio.h> #include<stdlib.h> #define Nmax 100000 + 10 int N; char s[Nmax]; char round[Nmax]; char animaltype[2] = {'S', 'W'}; int DP(); int main(){ scanf("%d", &N); scanf("%s", s); int check = -1; for(int i = 0; i < 4; i++){ round[0] = animaltype[i / 2]; round[1] = animaltype[i % 2]; check = DP(); if(check == 0){ break; } } if(check == 0){ for(int i = 0; i < N; i++){ printf("%c", round[i]); } }else{ printf("-1"); } system("pause"); return 0; } int DP(){ int buff; for(int i = 1; i < N; i++){ buff = 0; if(round[i] == animaltype[1]){ buff = 1; } if(round[i - 1] == animaltype[1]){ buff = (buff + 1) % 2; } if(s[i] == 'x'){ buff = (buff + 1) % 2; } if(i < N - 1){ round[i + 1] = animaltype[buff]; }else{ if(round[0] != animaltype[buff]){ return -1; } } } buff = 0; if(round[0] == animaltype[1]){ buff = 1; } if(round[N - 1] == animaltype[1]){ buff = (buff + 1) % 2; } if(s[0] == 'x'){ buff = (buff + 1) % 2; } if(round[1] == animaltype[buff]){ return 0; }else{ return -1; } }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | supercomputerjoi |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1159 Byte |
Status | AC |
Exec Time | 5 ms |
Memory | 640 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:14:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.cpp:15:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", s); ^ ./Main.cpp:32:17: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result] system("pause"); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 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 | 376 KB |
00_example_02.txt | AC | 1 ms | 376 KB |
00_example_03.txt | AC | 1 ms | 372 KB |
01.txt | AC | 3 ms | 628 KB |
02.txt | AC | 2 ms | 504 KB |
03.txt | AC | 1 ms | 376 KB |
04.txt | AC | 1 ms | 376 KB |
05.txt | AC | 4 ms | 632 KB |
06.txt | AC | 3 ms | 628 KB |
07.txt | AC | 2 ms | 384 KB |
08.txt | AC | 1 ms | 384 KB |
09.txt | AC | 1 ms | 376 KB |
10.txt | AC | 2 ms | 384 KB |
11.txt | AC | 5 ms | 640 KB |
12.txt | AC | 5 ms | 640 KB |
13.txt | AC | 4 ms | 640 KB |