Submission #415068

#TimeUsernameProblemLanguageResultExecution timeMemory
415068hhhhauraCircle selection (APIO18_circle_selection)C++14
49 / 100
3036 ms85424 KiB
#define wiwihorz #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i ++) #define rrep(i, a, b) for(int i = b; i >= a; i--) #define all(x) x.begin(), x.end() #define ceil(a, b) ((a + b - 1) / (b)) #define INF 100 #define MOD 1000000007 #define eps (1e-9) #define int long long int #define lld long double #define pii pair<int, int> #define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()) using namespace std; #ifdef wiwihorz #define print(a...) kout("[" + string(#a) + "] = ", a) void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L; } void kout() { cerr << endl; } template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);} #else #define print(...) 0 #define vprint(...) 0 #endif #define x first #define y second namespace solver { int n, r, c, w, ii; vector<unordered_set<int>> v; vector<pii> a; vector<int> vis, ord, rad; unordered_map<int, int> mp; void init_(int _n) { n = _n; a.assign(n + 1, {0, 0}); rad.assign(n + 1, 0); vis.assign(n + 1, 0); ord.clear(); mp.clear(); rep(i, 1, n) ord.push_back(i); } bool cmp(int a, int b) { if(rad[a] != rad[b]) return rad[a] > rad[b]; else return a < b; } int get_id(pii a) { int xx = (a.x + INF)/ w; int yy = (a.y + INF)/ w; return xx * c + yy; } void reconstruct(int x) { w = x, ii = 0; r = ceil(2 * INF, w); c = ceil(2 * INF, w); v.assign(n + 1, unordered_set<int>()); mp.clear(); rep(i, 1, n) if(!vis[i]) { pii cur = a[i]; int id = get_id(cur); if(mp.find(id) == mp.end()) { mp[id] = ++ii; } v[mp[id]].insert(i); } } int dis2(pii a, pii b) { return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y); } void operate(int id, int x) { rep(xx, -2, 2) rep(yy, -2, 2) { int i = xx * c + id + yy; if(mp.find(i) == mp.end()) continue; int bk = mp[i]; auto it = v[bk].begin(); while(it != v[bk].end()) { if(dis2(a[*it], a[x]) <= (rad[*it] + rad[x]) * (rad[*it] + rad[x])) { vis[*it] = x; auto cur = it; it = next(cur); v[bk].erase(cur); } else it = next(it); } } return; } void solve() { sort(all(ord), cmp); reconstruct(rad[ord[0]]); for(auto i : ord) if(!vis[i]) { if(rad[i] * 2 <= w) reconstruct(rad[i]); int id = get_id(a[i]); operate(id, i); } rep(i, 1, n) cout << vis[i] << " \n"[i == n]; } }; using namespace solver; signed main() { ios::sync_with_stdio(false), cin.tie(0); int n; cin >> n; init_(n); rep(i, 1, n) { cin >> a[i].x >> a[i].y; cin >> rad[i]; } solve(); return 0; }

Compilation message (stderr)

circle_selection.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
circle_selection.cpp:24:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L; }
      |             ^~~~
circle_selection.cpp:24:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L; }
      |                     ^~~~
#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...