Submission #1117281
Source Code Expand
#include<cstdio> #include<cstring> #include<algorithm> #include<cstring> #include<cmath> using namespace std; typedef long long LL; const int MaxN = 1e5 + 5; int n; char s[MaxN]; int ans[MaxN]; bool flag; void search(int x, int y){ int p = 0; ans[++p] = x; ans[++p] = y; for(int i = 2; i <= n; i++){ if(ans[i] == 1){ if(s[i] == 'o') ans[i + 1] = ans[i - 1]; else if(s[i] == 'x') ans[i + 1] = -ans[i - 1]; } else if(ans[i] == -1){ if(s[i] == 'o') ans[i + 1] = -ans[i - 1]; else if(s[i] == 'x') ans[i + 1] = ans[i - 1]; } } if(ans[1] == ans[1 + n]){ if(ans[1] == 1){ if(s[1] == 'o' && ans[2] == ans[n]) flag = true; else if(s[1] == 'x' && ans[2] != ans[n]) flag = true; } else if(ans[1] == -1){ if(s[1] == 'o' && ans[2] != ans[n]) flag = true; else if(s[1] == 'x' && ans[2] == ans[n]) flag = true; } } } int main(){ while(~scanf("%d", &n)){ scanf("%s", s + 1); for(int i = -1; i <= 1; i++){ for(int j = -1; j <= 1; j++){ if(i == 0 || j == 0) continue; if(!flag) search(i, j); } } if(!flag) printf("-1\n"); else{ for(int i = 1; i <= n; i++) if(ans[i] == 1) printf("S"); else if(ans[i] == -1) printf("W"); printf("\n"); } memset(ans, 0, sizeof(ans)); memset(s, 0, sizeof(s)); flag = false; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | ZZZZone |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1380 Byte |
Status | AC |
Exec Time | 4 ms |
Memory | 768 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:44: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 | 1 ms | 640 KB |
00_example_02.txt | AC | 1 ms | 640 KB |
00_example_03.txt | AC | 1 ms | 640 KB |
01.txt | AC | 2 ms | 768 KB |
02.txt | AC | 2 ms | 640 KB |
03.txt | AC | 1 ms | 640 KB |
04.txt | AC | 1 ms | 640 KB |
05.txt | AC | 3 ms | 768 KB |
06.txt | AC | 4 ms | 768 KB |
07.txt | AC | 1 ms | 640 KB |
08.txt | AC | 1 ms | 640 KB |
09.txt | AC | 1 ms | 640 KB |
10.txt | AC | 1 ms | 640 KB |
11.txt | AC | 3 ms | 768 KB |
12.txt | AC | 3 ms | 768 KB |
13.txt | AC | 3 ms | 768 KB |