結果
問題 | No.233 めぐるはめぐる (3) |
ユーザー | te-sh |
提出日時 | 2017-05-24 15:35:22 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 109 ms / 1,000 ms |
コード長 | 5,110 bytes |
コンパイル時間 | 1,949 ms |
コンパイル使用メモリ | 148,740 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 19:22:11 |
合計ジャッジ時間 | 5,083 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 76 ms
6,816 KB |
testcase_01 | AC | 50 ms
6,940 KB |
testcase_02 | AC | 25 ms
6,940 KB |
testcase_03 | AC | 55 ms
6,940 KB |
testcase_04 | AC | 108 ms
6,940 KB |
testcase_05 | AC | 95 ms
6,940 KB |
testcase_06 | AC | 92 ms
6,940 KB |
testcase_07 | AC | 109 ms
6,940 KB |
testcase_08 | AC | 109 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | AC | 1 ms
6,940 KB |
testcase_12 | AC | 52 ms
6,940 KB |
testcase_13 | AC | 79 ms
6,944 KB |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!size_t; auto si = n.iota.map!(_ => readln.chomp.s2l).array; si.sort(); foreach (vi; vowels) foreach (ci; consonants) foreach (li; lines) { auto a = merge(vi, ci, li); if (!si.assumeSorted.contains(a)) { writeln(a.l2s); return; } } writeln("NO"); } long merge(int[] vi, int[] ci, int[] li) { return (vi ~ ci).indexed(li).di2l; } long di2l(R)(R di) { auto l = 0L; foreach (d; di) { l *= 10; l += d; } return l; } long s2l(string s) { return s.map!(c => c.predSwitch('i',1,'a',2,'e',3,'u',4,'n',5,'b',6,'m',7,'g',8,'r',9)).di2l; } string l2s(long l) { int[] di; while (l > 0) { di = (l % 10) ~ di; l /= 10; } return di.map!(d => d.predSwitch(1,'i',2,'a',3,'e',4,'u',5,'n',6,'b',7,'m',8,'g',9,'r')).to!string; } auto vowels = [[1,2,2,3,4,4],[1,2,2,4,3,4],[1,2,2,4,4,3],[1,2,3,2,4,4],[1,2,3,4,2,4],[1,2,3,4,4,2],[1,2,4,2,3,4],[1,2,4,2,4,3],[1,2,4,3,2,4],[1,2,4,3,4,2],[1,2,4,4,2,3],[1,2,4,4,3,2],[1,3,2,2,4,4],[1,3,2,4,2,4],[1,3,2,4,4,2],[1,3,4,2,2,4],[1,3,4,2,4,2],[1,3,4,4,2,2],[1,4,2,2,3,4],[1,4,2,2,4,3],[1,4,2,3,2,4],[1,4,2,3,4,2],[1,4,2,4,2,3],[1,4,2,4,3,2],[1,4,3,2,2,4],[1,4,3,2,4,2],[1,4,3,4,2,2],[1,4,4,2,2,3],[1,4,4,2,3,2],[1,4,4,3,2,2],[2,1,2,3,4,4],[2,1,2,4,3,4],[2,1,2,4,4,3],[2,1,3,2,4,4],[2,1,3,4,2,4],[2,1,3,4,4,2],[2,1,4,2,3,4],[2,1,4,2,4,3],[2,1,4,3,2,4],[2,1,4,3,4,2],[2,1,4,4,2,3],[2,1,4,4,3,2],[2,2,1,3,4,4],[2,2,1,4,3,4],[2,2,1,4,4,3],[2,2,3,1,4,4],[2,2,3,4,1,4],[2,2,3,4,4,1],[2,2,4,1,3,4],[2,2,4,1,4,3],[2,2,4,3,1,4],[2,2,4,3,4,1],[2,2,4,4,1,3],[2,2,4,4,3,1],[2,3,1,2,4,4],[2,3,1,4,2,4],[2,3,1,4,4,2],[2,3,2,1,4,4],[2,3,2,4,1,4],[2,3,2,4,4,1],[2,3,4,1,2,4],[2,3,4,1,4,2],[2,3,4,2,1,4],[2,3,4,2,4,1],[2,3,4,4,1,2],[2,3,4,4,2,1],[2,4,1,2,3,4],[2,4,1,2,4,3],[2,4,1,3,2,4],[2,4,1,3,4,2],[2,4,1,4,2,3],[2,4,1,4,3,2],[2,4,2,1,3,4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