結果
問題 | No.873 バイナリ、ヤバいなり!w |
ユーザー | nebukuro09 |
提出日時 | 2019-08-30 22:28:52 |
言語 | D (dmd 2.106.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,094 bytes |
コンパイル時間 | 631 ms |
コンパイル使用メモリ | 101,508 KB |
実行使用メモリ | 250,140 KB |
最終ジャッジ日時 | 2023-09-04 02:37:14 |
合計ジャッジ時間 | 10,483 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | AC | 1,315 ms
124,368 KB |
testcase_02 | TLE | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; void main() { auto s = readln.split.map!(to!int); auto n = s[0]; auto dp = new int[](n + 1); auto ans = new bool[][](n + 1); bool[] tmp; dp[] = 1 << 29; dp[0] = 0; foreach (i; 0..n) { for (int j = 1; i + j * j <= n; ++j) { if (dp[i] + j < dp[i + j * j]) { dp[i + j * j] = dp[i] + j; ans[i + j * j] = ans[i]; bool last = i == 0 ? 0 : ans[i].back(); foreach (_; 0..j) ans[i + j * j] ~= last, last ^= 1; } else if (dp[i] + j == dp[i + j * j]) { tmp = ans[i].dup; bool last = i == 0 ? 0 : ans[i].back(); foreach (_; 0..j) tmp ~= last, last ^= 1; ans[i + j * j] = min(ans[i + j * j], tmp); } } } foreach (i; 0..ans[n].length) write(ans[n][i] ? 1 : 0); writeln; }