Submission #2834006
Source Code Expand
#if !defined(__clang__) && defined(__GNUC__) #include <bits/stdc++.h> #else #include <cstdlib> #include <climits> #include <iostream> #include <cstdint> #include <vector> #include <string> #include <complex> #include <bitset> #include <queue> #include <deque> #include <stack> #include <utility> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <regex> #endif // !defined(__clang__) && defined(__GNUG__) #include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> #include <boost/multi_array.hpp> #include <boost/optional.hpp> #include <boost/math/common_factor_rt.hpp> using namespace std; bool solve(char p2, char p1, auto& S) { char initP2 = p2; // 最後の仮定 char initP1 = p1; // 先頭の仮定 std::string ans; for (size_t i = 0; i < S.size(); ++i) { auto c = S[i]; char next; if (p2 == 'W' && p1 == 'W') { if (c == 'o') { next = 'S'; } else { next = 'W'; } } else if (p2 == 'S' && p1 == 'W') { if (c == 'o') { next = 'W'; } else { next = 'S'; } } else if (p2 == 'W' && p1 == 'S') { if (c == 'o') { next = 'W'; } else { next = 'S'; } } else { // p2 == 'S' && p1 == 'S' if (c == 'o') { next = 'S'; } else { next = 'W'; } } ans += p1; p2 = p1; p1 = next; } if (initP2 == ans[ans.size()-1] && initP1 == p1) { std::cout << ans << std::endl; return true; } return false; } int main() { int64_t N; std::cin >> N; std::string S; std::cin >> S; if (solve('W', 'S', S)) { return 0; } if (solve('S', 'S', S)) { return 0; } if (solve('W', 'W', S)) { return 0; } if (solve('S', 'W', S)) { return 0; } std::cout << "-1" << std::endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | sumomoneko |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 2194 Byte |
Status | AC |
Exec Time | 8 ms |
Memory | 640 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 | 512 KB |
02.txt | AC | 3 ms | 512 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 6 ms | 640 KB |
06.txt | AC | 5 ms | 640 KB |
07.txt | AC | 2 ms | 256 KB |
08.txt | AC | 2 ms | 384 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 2 ms | 256 KB |
11.txt | AC | 8 ms | 640 KB |
12.txt | AC | 8 ms | 640 KB |
13.txt | AC | 7 ms | 640 KB |