Submission #1116731
Source Code Expand
#ifdef __GNUC__ #pragma GCC optimize ("O3") #pragma GCC target ("avx") #endif #define _USE_MATH_DEFINES #include <iostream> #include <iomanip> #include <stdio.h> #include <sstream> #include <algorithm> #include <cmath> #include <string> #include <cstring> #include <vector> #include <valarray> //#include <array>//x C++ (G++ 4.6.4) #include <queue> #include <complex> #include <set> #include <map> #include <stack> #include <list> #include <cassert>//assert(); #include <fstream> #include <random> ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) ///////// typedef long long LL; typedef long double LD; typedef unsigned long long ULL; #define PII pair<int,int> ///////// using namespace::std; // 最大公約数 template<class T> inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;} //inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);} /*inline T gcd(T a,T b){ while(b != 0 ){ a = a % b; swap(a,b); } return a; }*/ // 最小公倍数 template<class T> inline T lcm(T a, T b){return a / gcd(a, b) * b;} //inline T lcm(T a, T b){return a * b / gcd(a, b);} //////////////////////////////// inline void solve(){ int N; string str; cin >> N >> str; vector< bool > ans(N+1);//false:x true:o vector< bool > ani(N+1,true);//false:w true:s vector< int > chan(N+1,0); for(int i=0;i<N;++i){ if( str[i] == 'o'){ ans[i] = true; }else{ ans[i] = false; } } ans[N] = ans[0]; int pos = 0; int L,R; int loop = 0; int Count = 0; bool flag = true; while(loop<N && Count < 3*N){ loop++; Count++; L = (pos+N-1)%N; R = (pos+1)%N; if( ani[pos] == true){//s if( ans[pos] == true ){ if( ani[L] != ani[R] ){ ani[R] = ani[L]; loop = 0; } }else{//false if( ani[L] == ani[R] ){ ani[R] = !ani[L]; loop = 0; } } }else{//w if( ans[pos] == false ){ if( ani[L] != ani[R] ){ ani[R] = ani[L]; loop = 0; } }else{//false if( ani[L] == ani[R] ){ ani[R] = !ani[L]; loop = 0; } } } //ani[0] = ani[N]; pos = (pos+1)%N; } if( loop == N ){ for(int i=0;i<N;++i){ if( ani[i] ){ cout << "S"; }else{ cout << "W"; } }cout << endl; }else{ cout << -1 << endl; } } signed main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); //std::cout << std::fixed;//小数を10進数表示 //cout << setprecision(16);//小数点以下の桁数を指定 solve(); }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | akarin55 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2581 Byte |
Status | WA |
Exec Time | 7 ms |
Memory | 896 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 | 4 ms | 640 KB |
02.txt | AC | 4 ms | 512 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | WA | 1 ms | 256 KB |
05.txt | WA | 6 ms | 768 KB |
06.txt | AC | 7 ms | 896 KB |
07.txt | WA | 2 ms | 384 KB |
08.txt | AC | 2 ms | 384 KB |
09.txt | WA | 1 ms | 256 KB |
10.txt | AC | 2 ms | 384 KB |
11.txt | WA | 6 ms | 848 KB |
12.txt | WA | 6 ms | 848 KB |
13.txt | WA | 6 ms | 848 KB |