Submission #3226284
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <map> #include <string> #include <cmath> #include <iomanip> #include <numeric> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define SORT(c) sort((c).begin(), (c).end()) #define INF 1e18 #define MOD 1e9 + 7 typedef long long ll; typedef pair<int, int> P; typedef vector<int> V; typedef map<int, int> M; int n; string s; vector<char> arr; bool solve(char fst, char scd) { arr.clear(); arr.push_back(fst); arr.push_back(scd); FOR(i, 1, n - 1) { if (arr[i] == 'S') { if (s[i] == 'o') arr.push_back(arr[i - 1]); else { arr.push_back(arr[i - 1] == 'S' ? 'W' : 'S'); } } else { if (s[i] == 'x') arr.push_back(arr[i - 1]); else { arr.push_back(arr[i - 1] == 'S' ? 'W' : 'S'); } } } if (arr[n - 1] == 'S') { if ((s[n - 1] == 'o' && arr[0] == arr[n - 2]) || (s[n - 1] == 'x' && arr[0] != arr[n - 2])) return true; else return false; } else { if ((s[n - 1] == 'x' && arr[0] == arr[n - 2]) || (s[n - 1] == 'o' && arr[0] != arr[n - 2])) return true; else return false; } } int main() { cin >> n >> s; if (!solve('S', 'S')) if (!solve('S', 'W')) if (!solve('W', 'S')) if (!solve('W', 'W')) { cout << -1 << endl; return 0; } REP(i, n) { cout << arr[i]; } cout << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | Kats |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1906 Byte |
Status | WA |
Exec Time | 9 ms |
Memory | 768 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 | 6 ms | 512 KB |
02.txt | AC | 4 ms | 512 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | WA | 8 ms | 768 KB |
06.txt | AC | 7 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 | 8 ms | 768 KB |
12.txt | WA | 8 ms | 768 KB |
13.txt | WA | 9 ms | 768 KB |