結果

問題 No.233 めぐるはめぐる (3)
ユーザー nebukuro09nebukuro09
提出日時 2016-11-02 13:29:02
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 183 ms / 1,000 ms
コード長 750 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 26,928 KB
最終ジャッジ日時 2023-09-02 22:42:04
合計ジャッジ時間 4,821 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
22,104 KB
testcase_01 AC 34 ms
10,836 KB
testcase_02 AC 19 ms
7,448 KB
testcase_03 AC 37 ms
11,300 KB
testcase_04 AC 142 ms
23,820 KB
testcase_05 AC 85 ms
22,376 KB
testcase_06 AC 139 ms
24,192 KB
testcase_07 AC 183 ms
26,928 KB
testcase_08 AC 179 ms
26,540 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 2 ms
4,368 KB
testcase_12 AC 35 ms
9,776 KB
testcase_13 AC 68 ms
21,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;

void main() {
  int N = readln().chomp.to!int;
  bool[string] used;
  foreach (i; iota(N))
    used[readln().chomp] = true;

  string s1 = "ieau";
  string s2 = "nbmgr";
  auto p1 = [0, 1, 2, 2, 3, 3];
  do {
    auto p2 = [0, 1, 2, 3, 4];
    do {
      string s3 = "";
      foreach (i; iota(5)) {
        s3 ~= s2[p2[i]];
        s3 ~= s1[p1[i]];
      }

      foreach (i; iota(11)) {
        if (!(s3[0..i]~s1[p1[5]]~s3[i..$] in used)) { 
          writeln(s3[0..i]~s1[p1[5]]~s3[i..$]);
          return;
        }
      }
    } while(nextPermutation(p2));
  } while(nextPermutation(p1));
  
  writeln("NO");
}
0