Submission #1117268
Source Code Expand
#include <cstdio> #include <algorithm> #include <cstring> #define NMAX (100000 + 7) using namespace std; int n, v[NMAX]; char s[NMAX]; bool p; void init() { for(int i = 1; i<= n; ++i) v[i] = 0; } bool build() { for(int i = 3; i<= n; ++i) { if(s[i-1] == 'o' && v[i-1] == 1) { v[i] = v[i-2]; continue; } if(s[i-1] == 'o' && v[i-1] == 2) { v[i] = 3 - v[i-2]; continue; } if(s[i-1] == 'x' && v[i-1] == 1) { v[i] = 3 - v[i-2]; continue; } v[i] = v[i-2]; } for(int i = 2; i<= n-1; ++i) { if(s[i] == 'o' && v[i] == 1 && v[i-1] != v[i+1]) return 0; if(s[i] == 'o' && v[i] == 2 && v[i-1] == v[i+1]) return 0; if(s[i] == 'x' && v[i] == 1 && v[i-1] == v[i+1]) return 0; if(s[i] == 'x' && v[i] == 2 && v[i-1] != v[i+1]) return 0; } if(s[1] == 'o' && v[1] == 1 && v[2] != v[n]) return 0; if(s[1] == 'o' && v[1] == 2 && v[2] == v[n]) return 0; if(s[1] == 'x' && v[1] == 1 && v[2] == v[n]) return 0; if(s[1] == 'x' && v[1] == 2 && v[2] != v[n]) return 0; if(s[n] == 'o' && v[n] == 1 && v[1] != v[n-1]) return 0; if(s[n] == 'o' && v[n] == 2 && v[1] == v[n-1]) return 0; if(s[n] == 'x' && v[n] == 1 && v[1] == v[n-1]) return 0; if(s[n] == 'x' && v[n] == 2 && v[1] != v[n-1]) return 0; return 1; } void afisare() { for(int i = 1; i<= n; ++i) { if(v[i] == 1) printf("S"); if(v[i] == 2) printf("W"); } printf("\n"); } int main() { scanf("%d", &n); scanf("%s", s+1); init(); v[1] = 1; v[2] = 1; p = build(); if(p == 1) { afisare(); return 0; } init(); v[1] = 1; v[2] = 2; p = build(); if(p == 1) { afisare(); return 0; } init(); v[1] = 2; v[2] = 1; p = build(); if(p == 1) { afisare(); return 0; } init(); v[1] = 2; v[2] = 2; p = build(); if(p == 1) { afisare(); return 0; } printf("-1\n"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | fluture |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 2262 Byte |
Status | AC |
Exec Time | 7 ms |
Memory | 768 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:66:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:67:21: 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 | 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 | 0 ms | 128 KB |
00_example_02.txt | AC | 0 ms | 128 KB |
00_example_03.txt | AC | 0 ms | 128 KB |
01.txt | AC | 4 ms | 512 KB |
02.txt | AC | 2 ms | 384 KB |
03.txt | AC | 1 ms | 128 KB |
04.txt | AC | 0 ms | 128 KB |
05.txt | AC | 5 ms | 640 KB |
06.txt | AC | 3 ms | 640 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | AC | 1 ms | 256 KB |
09.txt | AC | 1 ms | 128 KB |
10.txt | AC | 1 ms | 256 KB |
11.txt | AC | 7 ms | 768 KB |
12.txt | AC | 7 ms | 768 KB |
13.txt | AC | 6 ms | 768 KB |