結果

問題 No.233 めぐるはめぐる (3)
ユーザー むらためむらため
提出日時 2019-01-26 21:45:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 1,000 ms
コード長 1,442 bytes
コンパイル時間 2,828 ms
コンパイル使用メモリ 187,512 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-09-18 23:58:53
合計ジャッジ時間 5,605 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
8,448 KB
testcase_01 AC 29 ms
6,536 KB
testcase_02 AC 13 ms
5,376 KB
testcase_03 AC 36 ms
7,944 KB
testcase_04 AC 78 ms
8,584 KB
testcase_05 AC 57 ms
8,700 KB
testcase_06 AC 49 ms
8,572 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 26 ms
6,536 KB
testcase_13 AC 45 ms
8,704 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/exception_ptr.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/exception:168,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:3:
In function 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:182:11,
    inlined from 'void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algo.h:1107:18,
    inlined from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = char*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algo.h:2907:22,
    inlined from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = char*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algo.h:2947:2,
    inlined from 'int main()' at main.cpp:57:30:
/

ソースコード

diff #

#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include "bits/stdc++.h"

using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define ALL(a) begin(a), end(a)
#define let const auto
int scan() {
  int result = 0;
  while (true) {
    auto k = getchar_unlocked();
    if (k < '0' || k > '9') break;
    result = 10 * result + k - '0';
  }
  return result;
}
char S[] = "aaeiuu";
char C[] = "bgmnr";
char SC[] = "aaeiuubgmnr";
auto used = unordered_set<size_t>();
bool check(const char* str) {
  if (used.find(hash<string>()(str)) == used.end()) {
    printf("%s\n", str);
    return true;
  }
  return false;
}
char cache[] = "inabameguru";
signed main() {
  let n = scan();
  if (n == 129600) {  // 最大値は計算で出せる
    printf("NO\n");
    return 0;
  }
  REP(_, n) {
    scanf("%s", cache);
    // REP(i, 11) cache[i] = getchar_unlocked();
    used.insert(hash<string>()(cache));
    getchar_unlocked();
  };
  do {
    do {
      SC[0] = S[0];
      REP(i, 5) {
        SC[i * 2 + 2] = S[i + 1];
        SC[i * 2 + 1] = C[i];
      }
      REP(i, 5) {
        if (check(SC)) return 0;
        swap(SC[i * 2], SC[i * 2 + 1]);
      }
      if (check(SC)) return 0;
    } while (next_permutation(begin(C), end(C) - 1));
  } while (next_permutation(begin(S), end(S) - 1));
}
0