Submission #1248860
Source Code Expand
#include"bits/stdc++.h" //#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<b;i++) #define print(x) cout<<x<<endl; typedef long long ll; int n; string s; int int_s; int ans[100005]; string ans_s[100005]; bool is(int s1, int s2) { ans[0] = s1; //ans[i]=-1のとき羊、1の時狼 ans[1] = s2; rep(i, 1, n) { if (ans[i] == -1 && s[i] == 'o') { ans[i + 1] = ans[i - 1]; } else if (ans[i] == -1 && s[i] == 'x') { ans[i + 1] = -ans[i-1]; } else if (ans[i] == 1 && s[i] == 'o') { ans[i + 1] = -ans[i - 1]; } else if (ans[i] == 1 && s[i] == 'x') { ans[i + 1] = ans[i - 1]; } } //rep(i, 0, n )cout << ans[i]; //cout << endl; if (ans[n - 1] == -1 && s[n - 1] == 'o'&&ans[n - 2] == ans[0]) { return 1; } else if (ans[n - 1] == -1 && s[n - 1] == 'x'&&ans[n - 2] != ans[0]){ return 1;} else if (ans[n - 1] == 1 && s[n - 1] == 'o'&&ans[n - 2] != ans[0]) { return 1; } else if (ans[n - 1] == 1 && s[n - 1] == 'x'&&ans[n - 2] == ans[0]) { return 1; } else return 0; } int main() { cin >> n; cin >> s; int sw[8] = { -1,-1,-1,1,1,-1,1,1}; for(int i=0;i<8;i+=2) { //print(j); if (is(sw[i], sw[i+1])) { rep(j, 0, n) { if (ans[j] == -1) { ans_s[j] = 'S'; } else if (ans[j] == 1) { ans_s[j] = 'W'; } } rep(j, 0, n) { cout<<ans_s[j];} cout << endl; return 0; } } print(-1); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | ttakano |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1402 Byte |
Status | WA |
Exec Time | 18 ms |
Memory | 6272 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 | 2 ms | 1024 KB |
00_example_02.txt | AC | 2 ms | 1024 KB |
00_example_03.txt | AC | 2 ms | 1024 KB |
01.txt | WA | 12 ms | 4352 KB |
02.txt | AC | 9 ms | 3456 KB |
03.txt | AC | 2 ms | 1024 KB |
04.txt | AC | 2 ms | 1024 KB |
05.txt | WA | 16 ms | 5760 KB |
06.txt | AC | 15 ms | 5760 KB |
07.txt | WA | 4 ms | 1792 KB |
08.txt | AC | 4 ms | 1920 KB |
09.txt | AC | 2 ms | 1280 KB |
10.txt | WA | 5 ms | 2048 KB |
11.txt | WA | 17 ms | 6272 KB |
12.txt | WA | 17 ms | 6272 KB |
13.txt | WA | 18 ms | 6272 KB |