Submission #1853455
Source Code Expand
#include <iostream> #include <cstdio> using namespace std; int n, num[100005], a[100005]; string ta; bool f(int p) { int t1,t2; t1 = (p - 1 + n) % n; t2 = (p + 1) % n; if ((num[t1] ^ num[t2]) == (num[p] ^ a[p])) return true; else return false; } int main() { int i, j, k, t1, t2; cin >> n; cin >> ta; for (i = 0; i < n; i++) { if (ta[i] == 'o') a[i] = 0; else a[i] = 1; } for (i = 0; i< 2; i++) { for (j= 0; j< 2; j++) { num[0] = i; num[1] = j; // if (i == j && a[1] == 'x' || i != j && a[2] == 'o') continue; for (k = 1; k < n - 1; k++) { num[k+1]=((num[k - 1] ^ num[k]) ^ a[k]); // if (num[k] == 1) { // if (a[k] == 'o') num[k + 1] = num[k - 1]; // else num[k + 1] = 3 - num[k - 1]; // } else { // if (a[k] == 'o') num[k + 1] = 3 - num[k - 1]; // else num[k + 1] = num[k - 1]; // } } for (k = 0; k < n; k++) { if (!f(k)) break; } if (k == n) { for (k = 0; k < n; k++) { if (num[k] == 0) printf("S"); else printf("W"); } return 0; } } } cout << -1 << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | sean617 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1435 Byte |
Status | AC |
Exec Time | 8 ms |
Memory | 1408 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 | 896 KB |
02.txt | AC | 4 ms | 768 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 7 ms | 1280 KB |
06.txt | AC | 6 ms | 1280 KB |
07.txt | AC | 2 ms | 384 KB |
08.txt | AC | 2 ms | 512 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 2 ms | 512 KB |
11.txt | AC | 8 ms | 1308 KB |
12.txt | AC | 8 ms | 1408 KB |
13.txt | AC | 7 ms | 1408 KB |