Submission #1177791
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll query(int left, int now, char c) { if(now == 0) { return (c == 'o') ? left : (left+1) % 2; } return (c == 'x') ? left : (left+1) % 2; } int arr[100001]; const int dir[4][2] = {{0,0},{0,1},{1,0},{1,1}}; string solve(ll n, string s) { for(int x=0; x<4;x++) { for(int i=0; i< n; i++) { arr[i] = -1; } arr[0] = dir[x][0]; arr[1] = dir[x][1]; for(int i = 2; i < n; ++i) { arr[i] = query(arr[i-2], arr[i-1], s[i-1]); } // check if(arr[0] == query(arr[n-2], arr[n-1], s[n-1]) && arr[1] == query(arr[n-1], arr[0], s[0])) { string ret=""; for(int i=0;i<n;++i) { ret += (arr[i]==0)? "S" : "W"; } return ret; } } return "-1"; } int main() { ll n; string s; cin >> n >> s; cout<< solve(n, s)<<endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | udondon |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 928 Byte |
Status | AC |
Exec Time | 8 ms |
Memory | 1152 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 | 5 ms | 768 KB |
02.txt | AC | 3 ms | 640 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 6 ms | 1152 KB |
06.txt | AC | 5 ms | 1024 KB |
07.txt | AC | 2 ms | 384 KB |
08.txt | AC | 2 ms | 384 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 2 ms | 384 KB |
11.txt | AC | 8 ms | 1152 KB |
12.txt | AC | 8 ms | 1152 KB |
13.txt | AC | 7 ms | 1152 KB |