제출 #169769

#제출 시각아이디문제언어결과실행 시간메모리
169769ZwariowanyMarcin원 고르기 (APIO18_circle_selection)C++14
49 / 100
3051 ms351016 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define ss(x) (int) x.size() #define pb push_back #define ll long long #define cat(x) cerr << #x << " = " << x << endl #define FOR(i, n) for(int i = 0; i < n; ++i) using namespace std; const int INF = 2e9; struct circle { int x, y, r; }; bool inter(circle a, circle b) { return 1ll * (a.x - b.x) * (a.x - b.x) + 1ll * (a.y - b.y) * (a.y - b.y) <= 1ll * (a.r + b.r) * (a.r + b.r); } map <pair<int, int>, vector <int> > mapa; int n; circle t[300005]; int cur = INF; vector <int> v; int ans[300005]; void go() { mapa.clear(); for(int i = 1; i <= n; ++i) { if(ans[i]) continue; mapa[mp(t[i].x / cur, t[i].y / cur)].pb(i); } } vector <int> wywal; void solve(int x, int y, int id) { for(int i = 0; i < ss(mapa[mp(x, y)]); ++i) { auto it = mapa[mp(x, y)][i]; if(ans[it]) continue; if(inter(t[id], t[it])) { ans[it] = id; } else { wywal.pb(it); } } mapa[mp(x, y)] = wywal; wywal.clear(); } int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%d %d %d", &t[i].x, &t[i].y, &t[i].r); t[i].x += 1000000000; t[i].y += 1000000000; v.pb(i); } sort(v.begin(), v.end(), [](int a, int b) { if(t[a].r != t[b].r) return t[a].r < t[b].r; return a > b; }); go(); for(int i = n - 1; 0 <= i; --i) { int ja = v[i]; if(!ans[ja]) { if(2 * t[ja].r < cur) { cur = t[ja].r; go(); } for(int x = t[ja].x / cur - 2; x <= t[ja].x / cur + 2; ++x) for(int y = t[ja].y / cur - 2; y <= t[ja].y / cur + 2; ++y) solve(x, y, ja); } } for(int i = 1; i <= n; ++i) printf("%d ", ans[i]); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

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