Submission #49338

#TimeUsernameProblemLanguageResultExecution timeMemory
49338WLZCircle selection (APIO18_circle_selection)C++17
7 / 100
3043 ms8612 KiB
#include <bits/stdc++.h> using namespace std; int n; struct circle { int x, y, r, id; circle() { x = y = r = id = 0; } } arr[300005]; int ans[300005]; bool comp(const circle& a, const circle& b) { if (a.r == b.r) return a.id < b.id; return a.r > b.r; } bool inter(const circle& a, const circle& b) { long long dist = (a.x - b.x) * 1ll * (a.x - b.x) + (a.y - b.y) * 1ll * (a.y - b.y); return dist <= (a.r + b.r) * 1ll * (a.r + b.r); } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r); arr[i].id = i; } sort(arr + 1, arr + 1 + n, comp); for (int i = 1; i <= n; i++) ans[i] = i; for (int i = 1; i <= n; i++) { if (ans[arr[i].id] != arr[i].id) { continue; } for (int j = i + 1; j <= n; j++) { if (ans[arr[j].id] == arr[j].id) { if (inter(arr[i], arr[j])) { ans[arr[j].id] = arr[i].id; } } } } for (int i = 1; i <= n; i++) printf("%d ", ans[i]); return 0; }

Compilation message (stderr)

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
circle_selection.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...