Submission #1370071
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++) #define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++) #define SZ(x) ((int) (x).size()) typedef long long ll; bool solve(string s, string &ans) { int len = s.length(); char t = ans[0]; rep(i,1,len) { if(s[i]=='o') { if(ans[i]=='S' && ans[i-1]=='S') ans[(i+1)%len] = 'S'; else if(ans[i]=='S' && ans[i-1]=='W') ans[(i+1)%len] = 'W'; else if(ans[i]=='W' && ans[i-1]=='S') ans[(i+1)%len] = 'W'; else ans[(i+1)%len] = 'S'; } else { if(ans[i]=='S' && ans[i-1]=='S') ans[(i+1)%len] = 'W'; else if(ans[i]=='S' && ans[i-1]=='W') ans[(i+1)%len] = 'S'; else if(ans[i]=='W' && ans[i-1]=='S') ans[(i+1)%len] = 'S'; else ans[(i+1)%len] = 'W'; } } return t != ans[0] ? false : true; } const int MOD = (int)1e9 + 7; int main() { int n; string s; while(cin >> n >> s) { vector<string> vs = {"SS", "SW", "WS", "WW"}; bool flag = false; rep(i,0,4) { string ans(s.length(), ' '); ans[0] = vs[i][0]; ans[1] = vs[i][1]; if(solve(s, ans)) { cout << ans << endl; flag = true; break; } } if(!flag) cout << -1 << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | vino |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1377 Byte |
Status | WA |
Exec Time | 7 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 5 ms | 512 KB |
02.txt | AC | 3 ms | 384 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | WA | 6 ms | 640 KB |
06.txt | AC | 5 ms | 640 KB |
07.txt | WA | 2 ms | 256 KB |
08.txt | AC | 2 ms | 384 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | WA | 2 ms | 384 KB |
11.txt | WA | 6 ms | 640 KB |
12.txt | WA | 6 ms | 640 KB |
13.txt | WA | 7 ms | 640 KB |