結果
問題 | No.610 区間賞(Section Award) |
ユーザー |
|
提出日時 | 2017-12-11 11:05:05 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 1,049 bytes |
コンパイル時間 | 803 ms |
コンパイル使用メモリ | 106,384 KB |
実行使用メモリ | 9,212 KB |
最終ジャッジ日時 | 2024-06-12 22:58:31 |
合計ジャッジ時間 | 3,328 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
コンパイルメッセージ
Main.d(10): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!int; auto a = readln.split.to!(int[]); auto b = readln.split.to!(int[]); auto c = new int[](n+1); foreach (int i, ai; a) c[ai] = i; foreach (ref bi; b) bi = c[bi]; auto bt = BiTree!int(n); int[] r; foreach (bi; b) { if (bt[bi..$] == 0) r ~= bi; bt[bi] += 1; } foreach (ref ri; r) ri = a[ri]; r.sort(); foreach (ri; r) writeln(ri); } struct BiTree(T) { const size_t n; T[] buf; this(size_t n) { this.n = n; this.buf = new T[](n + 1); } void opIndexOpAssign(string op: "+")(T val, size_t i) { ++i; for (; i <= n; i += i & -i) buf[i] += val; } pure T opSlice(size_t r, size_t l) const { return get(l) - get(r); } pure size_t opDollar() const { return n; } pure T opIndex(size_t i) const { return opSlice(i, i+1); } private: pure T get(size_t i) const { auto s = T(0); for (; i > 0; i -= i & -i) s += buf[i]; return s; } }