Submission #1632634
Source Code Expand
// clang-format off #include <bits/stdc++.h> #define int long long #define main signed main() #define loop(i, a, n) for (int i = (a); i < (n); i++) #define rep(i, n) loop(i, 0, n) #define forever for (;;) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define prec(n) fixed << setprecision(n) template<typename A> using V = std::vector<A>; template<typename A> using F = std::function<A>; template<typename A, typename B> using P = std::pair<A, B>; using pii = P<int, int>; using vi = V<int>; using vd = V<double>; using vs = V<std::string>; using vpii = V<pii>; using vvi = V<vi>; using vvpii = V<vpii>; constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979; template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; } template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; } constexpr bool odd(const int n) { return n & 1; } constexpr bool even(const int n) { return ~n & 1; } template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; } template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; } using namespace std; // clang-format on main { int n; string s; cin >> n >> s; rep(i, 4) { string t; t += string(i & 1 ? "W" : "S") + string(i >> 1 & 1 ? "W" : "S"); rep(j, n - 2) { if (t[j + 1] == 'S') t += (s[j + 1] == 'o') ? t[j] : 'S' + 'W' - t[j]; if (t[j + 1] == 'W') t += (s[j + 1] == 'o') ? 'S' + 'W' - t[j] : t[j]; } bool valid = true; valid &= ((s[0] == 'o') == (t[0] == 'S')) == (t[1] == t[n - 1]); valid &= ((s[n - 1] == 'o') == (t[n - 1] == 'S')) == (t[0] == t[n - 2]); if (valid) { cout << t << endl; return 0; } } cout << -1 << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | AyaMorisawa |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 2049 Byte |
Status | AC |
Exec Time | 10 ms |
Memory | 776 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 | 4 ms | 512 KB |
03.txt | AC | 2 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 7 ms | 740 KB |
06.txt | AC | 5 ms | 640 KB |
07.txt | AC | 2 ms | 256 KB |
08.txt | AC | 3 ms | 384 KB |
09.txt | AC | 2 ms | 256 KB |
10.txt | AC | 3 ms | 384 KB |
11.txt | AC | 10 ms | 776 KB |
12.txt | AC | 10 ms | 776 KB |
13.txt | AC | 7 ms | 728 KB |