# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
137660 | 2019-07-28T08:21:21 Z | 송준혁(#3282) | Countries (BOI06_countries) | C++14 | 5 ms | 380 KB |
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL,LL> pii; int N; int X[1010], Y[1010], S[1010], C[1010]; bool D[1010]; pii R[1010], M[1010]; inline LL Sq(LL x){return x*x;} int main(){ scanf("%d", &N); for (int i=1; i<=N; i++){ scanf("%d %d %d", &X[i], &Y[i], &S[i]); R[i] = pii(S[i], i); M[i] = pii(S[i], 1), C[i] = i; } sort(R+1, R+N+1, greater<pii>()); for (int i=1; i<=N; i++){ int t = R[i].second; if (D[t]) C[t] = t; for (int j=1; j<=N; j++){ if (j == t) continue; if (M[j].first*(Sq(X[t]-X[j])+Sq(Y[t]-Y[j])) < S[t]*M[j].second){ M[j] = pii(S[t], Sq(X[t]-X[j])+Sq(Y[t]-Y[j])); C[j] = C[t], D[j] = false; } else if (M[j].first*(Sq(X[t]-X[j])+Sq(Y[t]-Y[j])) == S[t]*M[j].second && C[j] != j) D[j] = true; } } for (int i=1; i<=N; i++){ if (D[i]) puts("D"); else if (C[i] == i) puts("K"); else printf("%d\n", C[i]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 3 ms | 380 KB | Output is correct |
7 | Correct | 3 ms | 376 KB | Output is correct |
8 | Correct | 4 ms | 376 KB | Output is correct |
9 | Correct | 4 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
17 | Correct | 4 ms | 376 KB | Output is correct |
18 | Correct | 4 ms | 364 KB | Output is correct |
19 | Correct | 4 ms | 380 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |