QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#799985 | #1449. Mountain Skyline | hos_lyric# | WA | 0ms | 2924kb | D | 3.4kb | 2024-12-05 20:02:32 | 2024-12-05 20:02:33 |
Judging History
answer
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 N = readInt;
auto X = new long[N];
auto Y = new long[N];
auto Z = new long[N];
auto S = new string[N];
foreach (u; 0 .. N) {
X[u] = readLong;
Y[u] = readLong;
Z[u] = readLong;
S[u] = readToken;
}
int[] us;
foreach (u; 0 .. N) {
bool ok = true;
foreach (v; 0 .. N) if (u != v) {
/*
hide <=> \exists t s.t. 0 <= t <= 1 && t Z[u] <= Z[v] - |P[v] - t P[u]|
t Z[u] <= Z[v] - |P[v] - t P[u]|
<=> |P[v] - t P[u]| <= Z[v] - t Z[u]
<=> 0 <= Z[v] - t Z[u] && |P[v] - t P[u]|^2 <= (Z[v] - t Z[u])^2
<=> t <= Z[v]/Z[u] && a t^2 - 2 b t + c <= 0
*/
BigInt calc(int s, int t) {
return BigInt(X[s] * X[t] + Y[s] * Y[t] - Z[s] * Z[t]);
}
const a = calc(u, u);
const b = calc(u, v);
const c = calc(v, v);
// t = p/q
void check(BigInt p, BigInt q) {
// if (0 <= p && p <= q && p * Z[u] <= Z[v] * q) {
if (a * p*p - 2 * b * p*q + c * q*q <= 0) {
// debug writeln("hide ", [u, v], " ", [p, q]);
ok = false;
}
// }
}
// t = 0, 1, Z[v]/Z[u], b/a
const z = min(Z[u], Z[v]);
if (a > 0 && b > 0 && a * Z[u] <= z * b) {
check(b, a);
} else {
check(BigInt(z), BigInt(Z[u]));
}
if (!ok) break;
}
if (ok) {
us ~= u;
}
}
debug writeln("us = ", us);
us.sort!((int u, int v) {
const su = (X[u] > 0) ? 1 : (X[u] < 0) ? 3 : (Y[u] > 0) ? 0 : 2;
const sv = (X[v] > 0) ? 1 : (X[v] < 0) ? 3 : (Y[v] > 0) ? 0 : 2;
if (su != sv) return (su < sv);
const det = X[u] * Y[v] - Y[u] * X[v];
if (det) return (det < 0);
return (Z[u] > Z[v]);
});
debug writeln("us = ", us);
foreach (u; us) {
writeln(S[u]);
}
}
} catch (EOFException e) {
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 2924kb
input:
3 0 10000 8849 EVEREST 10000 0 5959 LOGAN 0 -10000 4808 BLANC
output:
EVEREST LOGAN BLANC
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 2896kb
input:
6 8 0 5 FUJI 9 1 5 MATTERHORN 9 0 5 KEBNEKAISE 9 -1 5 FAGRADALSFJALL 16 0 10 KILIMANJARO 120 0 80 DENALI
output:
DENALI
result:
wrong answer 1st lines differ - expected: 'MATTERHORN', found: 'DENALI'