結果
問題 | No.1170 Never Want to Walk |
ユーザー | allegrogiken |
提出日時 | 2020-08-15 00:30:45 |
言語 | D (dmd 2.106.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,792 bytes |
コンパイル時間 | 736 ms |
コンパイル使用メモリ | 116,272 KB |
実行使用メモリ | 11,428 KB |
最終ジャッジ日時 | 2024-06-22 08:04:02 |
合計ジャッジ時間 | 2,764 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,944 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | WA | - |
testcase_22 | AC | 45 ms
6,940 KB |
testcase_23 | AC | 14 ms
6,940 KB |
testcase_24 | AC | 47 ms
6,944 KB |
testcase_25 | AC | 44 ms
6,944 KB |
testcase_26 | AC | 28 ms
6,940 KB |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
ソースコード
void main() { problem(); } void problem() { auto N = scan!int; auto A = scan!long; auto B = scan!long; auto S = scan!long(N); const LEFT_LIMIT = 0; const RIGHT_LIMIT = S[$ - 1]; int[] Z = new int[RIGHT_LIMIT + 1]; int[long] ZP; auto ans = new long[N]; void solve() { foreach(i; 0..N-1) { Z[S[i] .. S[i + 1] ] = i + 1; ZP[S[i]] = i; } ZP.deb; Z[$-1] = N; foreach(stationIndex; 0..N) { if (ans[stationIndex] > 0) continue; bool[int] visits = [stationIndex: true]; bool[int] newVisits = visits; while(true) { bool[int] nextVisits; foreach(v; newVisits.keys) { visits[v] = true; if (S[v] + A <= RIGHT_LIMIT) { auto right_s = S[v] + A > RIGHT_LIMIT ? RIGHT_LIMIT : S[v] + A; auto right_e = S[v] + B > RIGHT_LIMIT ? RIGHT_LIMIT : S[v] + B; if (right_s == right_e) { if (right_s in ZP && !(ZP[right_s] in visits)) nextVisits[ZP[right_s]] = true; } else { foreach(n; Z[right_s] .. Z[right_e]) { if (!(n in visits)) nextVisits[n] = true; } } } if (S[v] - A >= LEFT_LIMIT) { auto left_s = S[v] - B < LEFT_LIMIT ? LEFT_LIMIT : S[v] - B; auto left_e = S[v] - A < LEFT_LIMIT ? LEFT_LIMIT : S[v] - A; if (left_s == left_e) { if (left_s in ZP && !(ZP[left_s] in visits)) { nextVisits[ZP[left_s]] = true; deb([[left_e]]); } } else { foreach(n; Z[left_s] .. Z[left_e]) { if (!(n in visits)) nextVisits[n] = true; } } } } if (nextVisits.length == 0) break; newVisits = nextVisits; newVisits.deb; } visits.deb; const reach = visits.length; foreach(v; visits.keys) { ans[v] = reach; } } foreach(a; ans) writeln(a); } solve(); } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric; T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); } string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; } void deb(T ...)(T t){ debug writeln(t); } alias Point = Tuple!(long, "x", long, "y"); // -----------------------------------------------