Submission #3767413
Source Code Expand
#include <bits/stdc++.h> #include <unordered_set> using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++) #define revrep(i,n) for(int (i)=(n)-1;i>=0; i--) void fill(vector<bool>& b, int n, string s) { repeat(i,2,n) { if(b[i-2]&&b[i-1]) { // ss if(s[i-1]=='o') { b[i]=true; } else { b[i]=false; } } if(!b[i-2]&&b[i-1]) { // ws if(s[i-1]=='o') { b[i]=false; } else { b[i]=true; } } if(b[i-2]&&!b[i-1]) { // sw if(s[i-1]=='o') { b[i]=false; } else { b[i]=true; } } if(!b[i-2]&&!b[i-1]) { // ww if(s[i-1]=='o') { b[i]=true; } else { b[i]=false; } } } } void print(vector<bool>& b) { for(auto x : b) { if(x) { cout << "S"; } else { cout << "W"; } } cout << endl; } bool check(vector<bool>& b, int n, string s) { rep(i,n) { if(b[i]&&s[i]=='o') { if(b[(i-1+n)%n]!=b[(i+1)%n]) return false; } if(b[i]&&s[i]=='x') { if(b[(i-1+n)%n]==b[(i+1)%n]) return false; } if(!b[i]&&s[i]=='o') { if(b[(i-1+n)%n]==b[(i+1)%n]) return false; } if(!b[i]&&s[i]=='x') { if(b[(i-1+n)%n]!=b[(i+1)%n]) return false; } } return true; } int main() { cin.tie(0); ios::sync_with_stdio(false); cout<<setprecision(std::numeric_limits<float>::max_digits10); int n; cin>>n; string s; cin>>s; vector<bool> b(n); // s=true,w=false; vector<bool> c = {true,false}; for(auto x1 : c) { for(auto x2 : c) { b[0]=x1; b[1]=x2; fill(b,n,s); if(check(b,n,s)) { print(b); return 0; } } } cout << -1 << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | ponpon05 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1935 Byte |
Status | AC |
Exec Time | 11 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 | 7 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 | 9 ms | 640 KB |
06.txt | AC | 6 ms | 640 KB |
07.txt | AC | 2 ms | 384 KB |
08.txt | AC | 2 ms | 384 KB |
09.txt | AC | 2 ms | 256 KB |
10.txt | AC | 2 ms | 256 KB |
11.txt | AC | 11 ms | 592 KB |
12.txt | AC | 11 ms | 592 KB |
13.txt | AC | 10 ms | 592 KB |