AtCoder Regular Contest 069

Submission #1365869

Source codeソースコード

#include <iostream>
#include <vector>

int main() {
  unsigned N;
  std::cin >> N;
  std::string s;
  std::cin >> s;
  std::vector<bool> sheep(N);
  auto same = [] (bool which, char c) {
    return (which == (c == 'o'));
  };
  for (unsigned i = 0; i < 4; ++i) {
    sheep[0] = i % 2 == 0;
    sheep[1] = i / 2 == 0;
    for (unsigned j = 2; j < N; ++j) {
      if (same(sheep[j-1], s[j-1])) {
        sheep[j] = sheep[j-2];
      } else {
        sheep[j] = !sheep[j-2];
      }
    }
    if (same(sheep[N-1], s[N-1]) == (sheep[N-2] == sheep[0])) {
      if (same(sheep[0], s[0]) == (sheep[N-1] == sheep[1])) {
        for (auto p = sheep.begin(); p < sheep.end(); ++p) {
          if (*p) { std::cout << "S"; }
          else { std::cout << "W"; }
        }
        return 0;
      }
    }
  }
  std::cout << -1;
  return 0;
}

Submission

Task問題 D - Menagerie
User nameユーザ名 079_ytsmiling
Created time投稿日時
Language言語 C++14 (Clang 3.8.0)
Status状態 AC
Score得点 500
Source lengthソースコード長 862 Byte
File nameファイル名
Exec time実行時間 13 ms
Memory usageメモリ使用量 888 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_example_01.txt,00_example_02.txt,00_example_03.txt
All 500 / 500 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_example_01.txt AC 7 ms 888 KB
00_example_02.txt AC 1 ms 256 KB
00_example_03.txt AC 1 ms 256 KB
01.txt AC 8 ms 512 KB
02.txt AC 5 ms 384 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 10 ms 512 KB
06.txt AC 9 ms 512 KB
07.txt AC 3 ms 256 KB
08.txt AC 3 ms 384 KB
09.txt AC 2 ms 256 KB
10.txt AC 3 ms 256 KB
11.txt AC 13 ms 576 KB
12.txt AC 13 ms 576 KB
13.txt AC 11 ms 576 KB