QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#799900 | #1449. Mountain Skyline | hos_lyric# | WA | 0ms | 3128kb | D | 2.8kb | 2024-12-05 19:27:30 | 2024-12-05 19:27:31 |
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;
const BigInt d2 = X[u] * X[u] + Y[u] * Y[u];
foreach (v; 0 .. N) if (u != v) {
const BigInt o = X[u] * X[v] + Y[u] * Y[v];
const BigInt e = abs(X[u] * Y[v] - Y[u] * X[v]);
// 0 < dot/sqrt < sqrt
if (!(0 < o && o < d2)) continue;
// |det|/sqrt <= Z[v]
// if (!(e * e <= (Z[v] * Z[v]) * d2)) continue;
// Z[u]/sqrt <= (Z[v] - |det|/sqrt) / (dot/sqrt)
const a = e * e * d2;
const b = Z[v] * d2 - Z[u] * o;
if (0 <= b && a <= b * b) {
ok = false;
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) {
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3040kb
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: 0
Accepted
time: 0ms
memory: 3032kb
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:
MATTERHORN DENALI FUJI FAGRADALSFJALL
result:
ok 4 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3128kb
input:
8 10 0 4 AX 0 10 4 AY -10 0 3 CX 0 -10 3 CY 6 0 2 BX -6 0 1 DX 0 6 2 BY 0 -6 1 DY
output:
AY BY AX BX CY DY CX DX
result:
ok 8 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 2892kb
input:
4 0 -6 1 D 0 6 2 B 0 -10 3 C 0 10 4 A
output:
A B C D
result:
ok 4 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 2900kb
input:
4 -6 0 1 D 6 0 2 B -10 0 3 C 10 0 4 A
output:
A B C D
result:
ok 4 lines
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 2896kb
input:
13 9898 -1123 9898 AAA 4949 -2123 4949 BBB 4949 -6923 4949 CCC 2 1 2 A 2 2 2 B 2 3 2 C 2 4 2 D 2 5 2 E -9897 1123 9897 AA -9897 3123 9897 BB -9897 9896 9897 CC -9897 9897 9897 DD -9897 9898 9897 EE
output:
E D C B A AAA BBB CCC AA BB CC DD EE
result:
wrong answer 1st lines differ - expected: 'A', found: 'E'