Submission #2216086
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++) #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() //sortで大きい順 #define UNIQUE(v) v.erase(unique(all(v)),v.end()) #define SUM(a) accumulate(all(a),0) #define pb push_back #define fst first #define snd second typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int,int> pii; typedef long long ll; int main(){ int n; cin >> n; string s; cin >> s; rep(i,2) rep(j,2){ // 0ならS,1ならW vi a(n); a[0] = i; a[1] = j; rep(k,n-2){ if(a[k+1] == 0) if(s[k+1] == 'o') a[k+2] = a[k]; else a[k+2] = not a[k]; else if(s[k+1] == 'x') a[k+2] = a[k]; else a[k+2] = not a[k]; } bool f = false; if(a[n-1] == 0) if(s[n-1] == 'o' and a[n-2] == a[0]) f = true; else if(s[n-1] == 'x' and a[n-2] != a[0]) f = true; else ; else if(s[n-1] == 'o' and a[n-2] != a[0]) f = true; else if(s[n-1] == 'x' and a[n-2] == a[0]) f = true; else ; if(not f) continue; f = false; if(a[0] == 0) if(s[0] == 'o' and a[n-1] == a[1]) f = true; else if(s[0] == 'x' and a[n-1] != a[1]) f = true; else ; else if(s[0] == 'o' and a[n-1] != a[1]) f = true; else if(s[0] == 'x' and a[n-1] == a[1]) f = true; else ; if(f){ rep(i,n) if(a[i] == 0) cout << "S"; else cout << "W"; cout << endl; return 0; } } cout << "-1\n"; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | kimitsu_emt |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1669 Byte |
Status | AC |
Exec Time | 13 ms |
Memory | 1016 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 | 644 KB |
02.txt | AC | 5 ms | 640 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 9 ms | 924 KB |
06.txt | AC | 8 ms | 896 KB |
07.txt | AC | 2 ms | 384 KB |
08.txt | AC | 3 ms | 384 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 2 ms | 384 KB |
11.txt | AC | 13 ms | 1016 KB |
12.txt | AC | 11 ms | 1016 KB |
13.txt | AC | 10 ms | 1016 KB |