제출 #328523

#제출 시각아이디문제언어결과실행 시간메모리
328523thecodingwizardPark (BOI16_park)C++11
0 / 100
9 ms492 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ii pair<int, int> #define f first #define s second #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define F0R(i, n) for (int i = 0; i < n; i++) #define FOR(i, a, b) for (int i = a; i < b; i++) #define inf 1000000010 bool can[4][4]; #define maxn 2000 bool wallTop[maxn], wallBot[maxn], wallLeft[maxn], wallRight[maxn]; struct object { int x, y, r; }; void updCan(int i) { //cout << i << endl; if (wallTop[i] && wallBot[i]) { //cout << "top & bot" << endl; can[0][1] = can[0][2] = can[3][1] = can[3][2] = can[1][0] = can[2][0] = can[1][3] = can[2][3] = 0; } if (wallTop[i] && wallLeft[i]) { //cout << "top & left" << endl; can[3][0] = can[3][1] = can[3][2] = can[0][3] = can[1][3] = can[2][3] = 0; } if (wallTop[i] && wallRight[i]) { //cout << "top & right" << endl; can[2][0] = can[2][1] = can[2][3] = can[0][2] = can[1][2] = can[3][2] = 0; } if (wallLeft[i] && wallRight[i]) { //cout << "left & right" << endl; can[2][0] = can[2][1] = can[0][2] = can[1][2] = can[0][3] = can[1][3] = can[3][1] = can[3][0] = 0; } if (wallLeft[i] && wallBot[i]) { //cout << "left & bot" << endl; can[0][3] = can[0][1] = can[0][2] = can[2][0] = can[1][0] = can[3][0] = 0; } if (wallRight[i] && wallBot[i]) { //cout << "right & bot" << endl; can[1][0] = can[1][3] = can[1][2] = can[0][1] = can[3][1] = can[2][1] = 0; } } int pa[maxn], sz[maxn]; int get(int x) { return pa[x] == x ? x : pa[x] = get(pa[x]); } void unite(int a, int b) { a = get(a), b = get(b); if (a == b) return; if (sz[a] > sz[b]) swap(a, b); sz[b] += sz[a]; pa[a] = b; wallTop[b] = wallTop[b] || wallTop[a]; wallBot[b] = wallBot[b] || wallBot[a]; wallLeft[b] = wallLeft[b] || wallLeft[a]; wallRight[b] = wallRight[b] || wallRight[a]; updCan(b); } vector<object> objects; ll getDist(int i, int j) { ll dx = abs(objects[i].x-objects[j].x); ll dy = abs(objects[i].y-objects[j].y); return dx*dx+dy*dy; } int main() { cin.tie(0)->sync_with_stdio(0); int n, m, w, h; cin >> n >> m >> w >> h; assert(m == 1); F0R(i, 4) F0R(j, 4) can[i][j] = true; F0R(i, n) { int x, y, r; cin >> x >> y >> r; objects.pb({x,y,r}); } F0R(i, n) { sz[i] = 1; pa[i] = i; } int r, e; cin >> r >> e; --e; F0R(i, n) { if (objects[i].y-objects[i].r < r) { wallBot[get(i)] = true; } if (h-objects[i].y-objects[i].r < r) { wallTop[get(i)] = true; } if (objects[i].x-objects[i].r < r) { wallLeft[get(i)] = true; } if (w-objects[i].x-objects[i].r < r) { wallRight[get(i)] = true; } updCan(get(i)); } F0R(i, n) { FOR(j, i+1, n) { ll r2 = (ll)2*r + objects[i].r + objects[j].r; //cout << i << " " << j << " " << getDist(i, j) << " " << r2*r2 << endl; if (getDist(i, j) < r2*r2) { //cout << "union " << i << " " << j << endl; unite(i, j); } } } F0R(i, 4) { if (can[e][i]) cout << i+1; } cout << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...