結果
問題 |
No.701 ひとりしりとり
|
ユーザー |
![]() |
提出日時 | 2020-03-15 23:47:10 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 1,855 ms |
コンパイル使用メモリ | 196,068 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-22 05:43:32 |
合計ジャッジ時間 | 2,845 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
import std; // AC: 263 ms void calc1(int n) { // 2^17 > 100_000 for (int i = 0; i < n-1; i++) { write('a'); for (int j = 0; j < 17; j++) { if (i & (1 << j)) write('a'); else write('b'); } writeln('a'); } writeln("an"); } // AC: 23 ms void calc2(int n) { auto cs = lowercase; // 26^4 > 100_000 foreach (a, b, c, d; cartesianProduct(cs, cs, cs, cs).take(n-1)) { writeln('a', a, b, c, d, 'a'); } writeln("an"); } void main() { int n; scan(n); calc2(n); } void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int;