結果
問題 | No.2771 Personal Space |
ユーザー | 👑 hos.lyric |
提出日時 | 2024-05-31 21:44:48 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 652 ms / 2,000 ms |
コード長 | 2,667 bytes |
コンパイル時間 | 1,039 ms |
コンパイル使用メモリ | 137,304 KB |
実行使用メモリ | 11,540 KB |
最終ジャッジ日時 | 2024-05-31 21:45:02 |
合計ジャッジ時間 | 11,635 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 310 ms
10,860 KB |
testcase_02 | AC | 308 ms
10,316 KB |
testcase_03 | AC | 309 ms
10,732 KB |
testcase_04 | AC | 310 ms
11,540 KB |
testcase_05 | AC | 309 ms
11,440 KB |
testcase_06 | AC | 309 ms
10,604 KB |
testcase_07 | AC | 269 ms
8,584 KB |
testcase_08 | AC | 652 ms
6,940 KB |
testcase_09 | AC | 268 ms
8,604 KB |
testcase_10 | AC | 293 ms
8,448 KB |
testcase_11 | AC | 303 ms
10,864 KB |
testcase_12 | AC | 303 ms
8,684 KB |
testcase_13 | AC | 320 ms
6,940 KB |
testcase_14 | AC | 273 ms
6,944 KB |
testcase_15 | AC | 276 ms
9,808 KB |
testcase_16 | AC | 276 ms
9,680 KB |
testcase_17 | AC | 280 ms
9,064 KB |
testcase_18 | AC | 270 ms
7,680 KB |
testcase_19 | AC | 277 ms
6,940 KB |
testcase_20 | AC | 304 ms
9,520 KB |
testcase_21 | AC | 300 ms
9,704 KB |
testcase_22 | AC | 302 ms
9,324 KB |
testcase_23 | AC | 306 ms
10,352 KB |
testcase_24 | AC | 308 ms
10,220 KB |
ソースコード
import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } string COLOR(string s = "") { return "\x1b[" ~ s ~ "m"; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } void main() { try { for (; ; ) { const numCases = readInt; foreach (caseId; 0 .. numCases) { const N = readInt; const M = readInt; alias Entry = Tuple!(int, "l", int, "m", int, "r"); auto ques = new BinaryHeap!(Array!Entry, "a.m > b.m")[N + 1]; void check(int l, int r) { if (l + 1 == r) return; int m, d; if (l == 0) { if (r == N + 1) { m = M; d = N; } else { m = 1; d = r - 1; } } else { if (r == N + 1) { m = N; d = N - l; } else { m = (l + r) / 2; d = m - l; } } ques[d].insert(Entry(l, m, r)); } check(0, N + 1); int[] sna; foreach_reverse (d; 1 .. N + 1) { for (; !ques[d].empty; ) { const e = ques[d].front; ques[d].removeFront; sna ~= e.m; check(e.l, e.m); check(e.m, e.r); } } debug { writeln("sna = ", sna); } assert(sna.length == N); auto ans = new int[N + 1]; foreach (i; 0 .. N) ans[sna[i]] = i; foreach (x; 1 .. N + 1) { if (x > 1) write(" "); write(ans[x] + 1); } writeln; } } } catch (EOFException e) { } }