#include <bits/stdc++.h>
//#define endl "\n"
using namespace std ;
typedef long long ll;
typedef long double ld ;
const int N=2e7;
const ll inf=1e18 ;
const ll mod = 1e9 + 7 ;
ll mypower(ll x, ll y){
if(y == 0) return 1 ;
if(y == 1) return x ;
ll ret = mypower(x , y / 2);
ret = (ret * ret) % mod;
if(y % 2) ret = ( ret * x ) % mod ;
return ret ;
}
ll n , x[20000] , y[200009] , s[200009] , in[200009] , di[200009] ;
bool vis[1009][1009] , from2[200009] ;
vector < ll > v[200009] ;
void dfs(ll node , ll root){
if(vis[node][root])
return ;
vis[node][root] = 1 ;
if(di[node] != -1){
from2[node] = 1 ;
}
else{
di[node] = root ;
}
for(auto p : v[node]){
if(vis[p][root] == 0){
ll q = (x[node] - x[p]) * (x[node] - x[p]) + (y[node] - y[p]) * (y[node] - y[p]) ;
ll e = s[root]/ q ;
if(e > s[p])
dfs(p , root) ;
}
}
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n ;
for(int i = 0 ; i < n ; i++){
cin >> x[i] >> y[i] >> s[i] ;
di[i] = -1 ;
}
for(int i = 0 ; i < n ; i++){
for(int j = 0; j < n ; j++){
if(i == j)
continue ;
ll q = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) ;
ll e = s[j] / q ;
if(e > s[i]){
v[j].push_back(i) ;
in[i]++ ;
}
}
}
for(int i = 0 ; i < n ; i++){
if(in[i] == 0){
dfs(i , i) ;
}
}
for(int i = 0 ; i < n ; i++){
if(di[i] == i){
cout << "K" << endl ;
}
else if(from2[i] == 1){
cout << "D" << endl ;
}
else{
cout << di[i] + 1 << endl;
}
}
return 0 ;
}
/*
5
2 5 14
2 3 2
3 2 7
1 1 2
2 1 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
5068 KB |
Output isn't correct |
2 |
Incorrect |
4 ms |
5196 KB |
Output isn't correct |
3 |
Incorrect |
4 ms |
5324 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
5452 KB |
Output isn't correct |
5 |
Incorrect |
6 ms |
5452 KB |
Output isn't correct |
6 |
Incorrect |
7 ms |
5580 KB |
Output isn't correct |
7 |
Incorrect |
7 ms |
5708 KB |
Output isn't correct |
8 |
Incorrect |
7 ms |
5836 KB |
Output isn't correct |
9 |
Incorrect |
8 ms |
5964 KB |
Output isn't correct |
10 |
Incorrect |
9 ms |
6092 KB |
Output isn't correct |
11 |
Correct |
3 ms |
5068 KB |
Output is correct |
12 |
Incorrect |
3 ms |
5196 KB |
Output isn't correct |
13 |
Correct |
4 ms |
5324 KB |
Output is correct |
14 |
Incorrect |
4 ms |
5452 KB |
Output isn't correct |
15 |
Incorrect |
5 ms |
5452 KB |
Output isn't correct |
16 |
Incorrect |
5 ms |
5580 KB |
Output isn't correct |
17 |
Incorrect |
6 ms |
5708 KB |
Output isn't correct |
18 |
Incorrect |
7 ms |
5836 KB |
Output isn't correct |
19 |
Incorrect |
10 ms |
5836 KB |
Output isn't correct |
20 |
Incorrect |
11 ms |
5964 KB |
Output isn't correct |