結果
| 問題 |
No.759 悪くない忘年会にしような!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-05 15:09:45 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 129 ms / 2,000 ms |
| コード長 | 2,855 bytes |
| コンパイル時間 | 1,346 ms |
| コンパイル使用メモリ | 133,500 KB |
| 実行使用メモリ | 12,880 KB |
| 最終ジャッジ日時 | 2024-06-13 04:50:55 |
| 合計ジャッジ時間 | 6,581 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 64 |
ソースコード
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, 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; }
real readReal() { return readToken.to!real; }
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)); }
enum LIM = 10^^4;
int[] bit;
void update(int pos, int val) {
for (int x = pos; x < bit.length; x |= x + 1) {
chmin(bit[x], val);
}
}
int rangeMin(int pos) {
int mn = LIM + 1;
for (int x = pos - 1; x >= 0; x = (x & (x + 1)) - 1) {
chmin(mn, bit[x]);
}
return mn;
}
int N;
Tuple!(int, "a", int, "b", int, "c", int, "id")[] P;
void main() {
try {
for (; ; ) {
N = readInt();
P.length = N;
foreach (i; 0 .. N) {
P[i].a = readInt();
P[i].b = readInt();
P[i].c = readInt();
P[i].id = i;
}
foreach (i; 0 .. N) {
P[i].a = LIM - P[i].a;
P[i].b = LIM - P[i].b;
P[i].c = LIM - P[i].c;
}
P.sort;
auto ans = new bool[N];
bit = new int[LIM + 1];
bit[] = LIM + 1;
for (int j = 0, k; j < N; j = k) {
for (k = j; k < N && P[j].a == P[k].a; ++k) {}
debug {
writeln(P[j .. k]);
}
foreach (p; P[j .. k]) {
if (rangeMin(p.b + 1) <= p.c) {
debug {
writeln("found(a) ", p);
}
ans[p.id] = true;
}
}
foreach (p; P[j .. k]) {
update(p.b, p.c);
}
foreach (p; P[j .. k]) {
if (rangeMin(p.b) <= p.c) {
debug {
writeln("found(b) ", p);
}
ans[p.id] = true;
}
if (rangeMin(p.b + 1) < p.c) {
debug {
writeln("found(c) ", p);
}
ans[p.id] = true;
}
}
}
foreach (i; 0 .. N) {
if (!ans[i]) {
writeln(i + 1);
}
}
}
} catch (EOFException e) {
}
}