Submission #1351647


Source Code Expand

#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
char s[N], ret[N];

int n;
bool valid(int x) {
  if (ret[x] == 'W') {
    if (s[x] == 'o') {
      return ret[(x + n - 1) % n] != ret[(x + 1) % n];
    } else {
      return ret[(x + n - 1) % n] == ret[(x + 1) % n];
    }
  } else {
    if (s[x] == 'x') {
      return ret[(x + n - 1) % n] != ret[(x + 1) % n];
    } else {
      return ret[(x + n - 1) % n] == ret[(x + 1) % n];
    }
  }
}

int main() {
  bool found = false;
  scanf("%d%s", &n, s);
  for (int k = 0; k < 4; ++k) {
    ret[0] = (k & 1) ? 'W' : 'S';
    ret[1] = (k & 2) ? 'W' : 'S';
    for (int i = 2; i < n; ++i) {
      if (ret[i - 1] == 'W') {
        if (s[i - 1] == 'o') {
          ret[i] = 'W' + 'S' - ret[i - 2];
        } else {
          ret[i] = ret[i - 2];
        }
      } else {
        if (s[i - 1] == 'o') {
          ret[i] = ret[i - 2];
        } else {
          ret[i] = 'W' + 'S' - ret[i - 2];
        }
      }
    }
    if (valid(n - 1) && valid(1)) {
      found = true;
      break;
    }
  }
  if (!found) {
    puts("-1");
  } else {
    puts(ret);
  }
  return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User cuiaoxiang
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2083 Byte
Status WA
Exec Time 3 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:63:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%s", &n, s);
                       ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 11
WA × 5
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 2 ms 384 KB
02.txt AC 2 ms 384 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 2 ms 512 KB
06.txt AC 2 ms 512 KB
07.txt WA 1 ms 256 KB
08.txt WA 1 ms 256 KB
09.txt AC 1 ms 256 KB
10.txt WA 1 ms 256 KB
11.txt WA 2 ms 512 KB
12.txt WA 2 ms 512 KB
13.txt AC 3 ms 512 KB