#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
#define sz(v) ((int)((v).size()))
const int MAXN = 1005;
int n, x[MAXN], y[MAXN], s[MAXN];
string ans[MAXN];
int par[MAXN];
bool cmp(pi a, pi b){
return 1ll * a.first * b.second < 1ll * b.first * a.second;
}
int main(){
cin >> n;
for(int i=0; i<n; i++) cin >> x[i] >> y[i] >> s[i];
for(int i=0; i<n; i++){
pi rt(s[i], 1);
int cnt = 0;
int pos = -1;
for(int j=0; j<n; j++){
if(i == j) continue;
int dist = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
pi rat = pi(s[j], dist);
if(cmp(rt, rat)){
rt = rat;
}
if(!cmp(rt, rat) && !cmp(rat, rt)){
cnt++;
pos = j;
}
}
if(!cmp(pi(s[i], 1), rt)){
ans[i] = "K";
}
else{
if(cnt == 1){
ans[i] = "?";
par[i] = pos;
}
else{
ans[i] = "D";
}
}
}
for(int i=0; i<n; i++){
if(ans[i] != "?") cout << ans[i] << endl;
else{
int pos = i;
while(ans[pos] == "?") pos = par[pos];
cout << pos + 1 << endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
6 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
7 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
7 ms |
376 KB |
Output isn't correct |
9 |
Incorrect |
7 ms |
376 KB |
Output isn't correct |
10 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
15 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
16 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
17 |
Correct |
6 ms |
376 KB |
Output is correct |
18 |
Incorrect |
7 ms |
376 KB |
Output isn't correct |
19 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
20 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |