Submission #1118897
Source Code Expand
#include <iostream> #include <string> using namespace std; char data[100000]; char type[2]={'S','W'}; int main(){ int N; string s; cin>>N; cin>>s; string ans; bool exit=false; for (int first=0;first<2&&!exit;first++) for (int second=0;second<2&&!exit;second++) { data[0]=type[first]; data[1]=type[second]; for (int i=1;i<N-1;i++){ if(data[i]=='S'){ if(s[i]=='o')data[i+1]=data[i-1]; else data[i+1]=(data[i-1]=='S')?'W':'S'; } else { if(s[i]=='o')data[i+1]=(data[i-1]=='S')?'W':'S'; else data[i+1]=data[i-1]; } } bool flag1 = false, flag2 = false; if (data[N-1]=='S'){ if(s[N-1]=='o'&&(data[N-2]==data[0]))flag1=true; else if(s[N-1]=='x'&&(data[N-2]!=data[0]))flag1=true; } else { if(s[N-1]=='o'&&(data[N-2]!=data[0]))flag1=true; else if(s[N-1]=='x'&&(data[N-2]==data[0]))flag1=true; } if (data[0]=='S'){ if(s[0]=='o'&&(data[N-1]==data[1]))flag2=true; else if(s[0]=='x'&&(data[N-1]!=data[1]))flag2=true; } else { if(s[0]=='o'&&(data[N-1]!=data[1]))flag2=true; else if(s[0]=='x'&&(data[N-1]==data[1]))flag2=true; } if (flag1&&flag2)exit=true; } if (exit) { for (int i=0;i<N;i++) cout<<data[i]; cout<<endl; } else cout<<"-1"<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | shouta |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1329 Byte |
Status | AC |
Exec Time | 10 ms |
Memory | 640 KB |
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 | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
00_example_03.txt | AC | 1 ms | 256 KB |
01.txt | AC | 6 ms | 512 KB |
02.txt | AC | 4 ms | 384 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 8 ms | 640 KB |
06.txt | AC | 7 ms | 640 KB |
07.txt | AC | 2 ms | 256 KB |
08.txt | AC | 2 ms | 384 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 2 ms | 256 KB |
11.txt | AC | 10 ms | 640 KB |
12.txt | AC | 9 ms | 640 KB |
13.txt | AC | 9 ms | 640 KB |