// And you curse yourself for things you never done
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 3e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;
pair<pii, int> p[maxn];
int arr[maxn];
pii operator - (pii a, pii b){
return {a.F - b.F, a.S - b.S};
}
pii operator + (pii a, pii b){
return {a.F + b.F, a.S + b.S};
}
ll operator ^ (pii a, pii b){
return 1ll * a.F * b.F + 1ll * a.S * b.S;
}
bool ok(int i, int j){
return 1ll * (p[j].S + p[i].S) * (p[j].S + p[i].S) >= ((p[i].F - p[j].F) ^ (p[i].F - p[j].F));
}
int ans[maxn];
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();
int n;
cin >> n;
for(int i = 0; i < n; i++){
cin >> p[i].F.F >> p[i].F.S >> p[i].S;
arr[i] = i;
}
sort(arr, arr + n, [](int i, int j){ return (p[i].S == p[j].S ? i > j : p[i].S < p[j].S); } );
for(int i = n-1; i >= 0; i--){
if(ans[ arr[i] ] == 0){
for(int j = i; j >= 0; j--){
if(ans[ arr[j] ] == 0 && ok(arr[i], arr[j]))
ans[ arr[j] ] = arr[i] + 1;
}
}
}
for(int i = 0; i < n; i++){
cout << ans[i] << " ";
}
return cout << endl, 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
640 KB |
Output is correct |
20 |
Correct |
4 ms |
640 KB |
Output is correct |
21 |
Correct |
4 ms |
640 KB |
Output is correct |
22 |
Correct |
46 ms |
760 KB |
Output is correct |
23 |
Correct |
46 ms |
636 KB |
Output is correct |
24 |
Correct |
45 ms |
640 KB |
Output is correct |
25 |
Correct |
59 ms |
640 KB |
Output is correct |
26 |
Correct |
49 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
186 ms |
8312 KB |
Output is correct |
2 |
Correct |
198 ms |
15068 KB |
Output is correct |
3 |
Correct |
174 ms |
14712 KB |
Output is correct |
4 |
Correct |
171 ms |
15096 KB |
Output is correct |
5 |
Execution timed out |
3015 ms |
10872 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Execution timed out |
3069 ms |
2424 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3081 ms |
5220 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
640 KB |
Output is correct |
20 |
Correct |
4 ms |
640 KB |
Output is correct |
21 |
Correct |
4 ms |
640 KB |
Output is correct |
22 |
Correct |
46 ms |
760 KB |
Output is correct |
23 |
Correct |
46 ms |
636 KB |
Output is correct |
24 |
Correct |
45 ms |
640 KB |
Output is correct |
25 |
Correct |
59 ms |
640 KB |
Output is correct |
26 |
Correct |
49 ms |
640 KB |
Output is correct |
27 |
Correct |
7 ms |
1024 KB |
Output is correct |
28 |
Correct |
7 ms |
896 KB |
Output is correct |
29 |
Correct |
6 ms |
896 KB |
Output is correct |
30 |
Correct |
183 ms |
888 KB |
Output is correct |
31 |
Correct |
178 ms |
888 KB |
Output is correct |
32 |
Correct |
179 ms |
888 KB |
Output is correct |
33 |
Correct |
66 ms |
6008 KB |
Output is correct |
34 |
Correct |
68 ms |
6008 KB |
Output is correct |
35 |
Correct |
68 ms |
5880 KB |
Output is correct |
36 |
Execution timed out |
3099 ms |
4856 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
640 KB |
Output is correct |
20 |
Correct |
4 ms |
640 KB |
Output is correct |
21 |
Correct |
4 ms |
640 KB |
Output is correct |
22 |
Correct |
46 ms |
760 KB |
Output is correct |
23 |
Correct |
46 ms |
636 KB |
Output is correct |
24 |
Correct |
45 ms |
640 KB |
Output is correct |
25 |
Correct |
59 ms |
640 KB |
Output is correct |
26 |
Correct |
49 ms |
640 KB |
Output is correct |
27 |
Correct |
186 ms |
8312 KB |
Output is correct |
28 |
Correct |
198 ms |
15068 KB |
Output is correct |
29 |
Correct |
174 ms |
14712 KB |
Output is correct |
30 |
Correct |
171 ms |
15096 KB |
Output is correct |
31 |
Execution timed out |
3015 ms |
10872 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |