제출 #1118900

#제출 시각아이디문제언어결과실행 시간메모리
1118900OI_Account원 고르기 (APIO18_circle_selection)C++17
0 / 100
139 ms19304 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 300'000; ll n, x[N + 10], y[N + 10], r[N + 10]; int ans[N + 10], id[N + 10]; pair<int, int> p[N + 10]; void readInput() { cin >> n; for (int i = 1; i <= n; i++) { cin >> x[i] >> y[i] >> r[i]; p[i] = {r[i], -i}; } sort(p + 1, p + n + 1); for (int i = 1; i <= n; i++) id[i] = -p[i].second; } ll p2(ll x) { return x * x; } bool check(int i, int j) { ll dis = p2(x[i] - x[j]) + p2(y[i] - y[j]); return dis <= r[i] + r[j]; } void solve1() { for (int i = n; i >= 1; i--) if (!ans[id[i]]) { ans[id[i]] = id[i]; for (int j = 1; j < i; j++) if (check(id[i], id[j]) && !ans[id[j]]) ans[id[j]] = id[i]; } } void writeOutput() { for (int i = 1; i <= n; i++) cout << ans[i] << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); readInput(); if (n <= 5000) solve1(); writeOutput(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...