Submission #1116586
Source Code Expand
#include <cmath> #include <cstdio> #include <cstring> #include <set> #include <map> #include <stack> #include <queue> #include <vector> #include <string> #include <numeric> #include <sstream> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; #define MAXN 100111 bool solve(int ans[], int a[], int n) { for(int i=2; i<=n+1; ++i) { if(ans[i-1] == 1) ans[i] = a[i-1] ? ans[i-2] : 1-ans[i-2]; else ans[i] = (1-a[i-1]) ? ans[i-2] : 1-ans[i-2]; } return ans[0] == ans[n] && ans[1] == ans[n+1]; } int main() { ios::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; int a[MAXN]; for(int i=0; i<n; ++i) a[i] = s[i] == 'o' ? 1 : 0; a[n] = a[0]; a[n+1] = a[1]; int ans[MAXN]; for(int i=0; i<4; ++i) { ans[0] = i/2; ans[1] = i%2; if(solve(ans, a, n)) { for(int j=0; j<n; ++j) cout << (ans[j] ? 'S' : 'W'); cout << "\n"; return 0; } } cout << "-1\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | T1024 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1018 Byte |
Status | AC |
Exec Time | 6 ms |
Memory | 1360 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 | 4 ms | 1024 KB |
02.txt | AC | 3 ms | 768 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 5 ms | 1280 KB |
06.txt | AC | 6 ms | 1280 KB |
07.txt | AC | 2 ms | 384 KB |
08.txt | AC | 2 ms | 512 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 2 ms | 512 KB |
11.txt | AC | 5 ms | 1360 KB |
12.txt | AC | 5 ms | 1360 KB |
13.txt | AC | 5 ms | 1360 KB |