Submission #2671844
Source Code Expand
/*----------------by syr----------------*/ #include<algorithm> #include<bitset> #include<cctype> #include<cstring> #include<cstdlib> #include<deque> #include<fstream> #include<functional> #include<iomanip> #include<iostream> #include<limits> #include<list> #include<map> #include<math.h> #include<queue> #include<set> #include<stack> #include<stdio.h> #include<sstream> #include<string> #include<time.h> #include<utility> #include<vector> using namespace std; const int INF=1e9+7; int n; int a[100005]; char s[100005]; bool judge(int p){ int l=p-1+n,r=p+1; l%=n;r%=n; if(a[p]==0){ if(s[p]=='o'&&a[l]==a[r]) return true; else if(s[p]=='x'&&a[l]!=a[r]) return true; }else{ if(s[p]=='o'&&a[l]!=a[r]) return true; else if(s[p]=='x'&&a[l]==a[r]) return true; } return false; } void arrange(){ for(int i=1;i<n-1;i++){ int l=i-1,r=i+1; if(a[i]==0){ if(s[i]=='o') a[r]=a[l]; else a[r]=a[l]^1; }else{ if(s[i]=='o') a[r]=a[l]^1; else a[r]=a[l]; } } if(judge(0)&&judge(n-1)){ for(int i=0;i<n;i++){ if(a[i]==0) printf("S"); else printf("W"); } puts(""); exit(0); } } int main(){ scanf("%d",&n); scanf("%s",s); for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ memset(a,-1,sizeof(a)); a[0]=i,a[1]=j; arrange(); } } puts("-1"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | Ling2Feng1 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1377 Byte |
Status | AC |
Exec Time | 5 ms |
Memory | 768 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:69:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:70:15: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s",s); ^
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 | 3 ms | 768 KB |
02.txt | AC | 2 ms | 768 KB |
03.txt | AC | 1 ms | 640 KB |
04.txt | AC | 1 ms | 640 KB |
05.txt | AC | 4 ms | 768 KB |
06.txt | AC | 3 ms | 768 KB |
07.txt | AC | 2 ms | 640 KB |
08.txt | AC | 2 ms | 640 KB |
09.txt | AC | 1 ms | 640 KB |
10.txt | AC | 2 ms | 640 KB |
11.txt | AC | 5 ms | 768 KB |
12.txt | AC | 5 ms | 768 KB |
13.txt | AC | 4 ms | 768 KB |