Submission #1070992

#TimeUsernameProblemLanguageResultExecution timeMemory
1070992pawnedCircle selection (APIO18_circle_selection)C++17
0 / 100
3081 ms283604 KiB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops") #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; const char nl = '\n'; void fastIO() { ios::sync_with_stdio(false); cin.tie(0); } int dirX[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; int dirY[9] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; int N, R; int flat(int x, int y) { if (x >= 0) return x / y; else return -((-x + y - 1) / y); } bool intersect(ii c1, ii c2) { ll dx = abs(c1.fi - c2.fi); ll dy = abs(c1.se - c2.se); if (4 * R * R >= dx * dx + dy * dy) return true; return false; } int main() { fastIO(); int N; cin>>N; vector<ii> cr(N); // {{x, y}, r} for (int i = 0; i < N; i++) { cin>>cr[i].fi>>cr[i].se; cin>>R; } // cout<<"R: "<<R<<endl; vector<ii> ft(N); map<ii, set<int>> all; for (int i = 0; i < N; i++) { ft[i] = {flat(cr[i].fi, 2 * R), flat(cr[i].se, 2 * R)}; all[ft[i]].insert(i); } vector<bool> vis(N, false); vi par(N, -1); for (int i = 0; i < N; i++) { if (vis[i]) continue; int xc = ft[i].fi; int yc = ft[i].se; for (int j = 0; j < 9; j++) { int xn = xc + dirX[j]; int yn = yc + dirY[j]; vi toerase; for (int x : all[{xn, yn}]) { if (!vis[x] && intersect(cr[i], cr[x])) { vis[x] = true; par[x] = i; toerase.pb(x); } } for (int x : toerase) all[{xn, yn}].erase(x); } } // cout<<"ANSWER: "; for (int x : par) cout<<x<<" "; cout<<endl; }
#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...