제출 #1099421

#제출 시각아이디문제언어결과실행 시간메모리
1099421TrieTrPark (BOI16_park)C++14
100 / 100
244 ms71312 KiB
#include<bits/stdc++.h> using namespace std; void local() { #define taskname "" if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } } #define ll long long #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); template<class X, class Y> bool mini(X &a, const Y &b) {return (a > b) ? a = b, true : false;} template<class X, class Y> bool maxi(X &a, const Y &b) {return (a < b) ? a = b, true : false;} const int N = 1e6 + 5; struct DSU { vector<int>lab; void init(int n) { lab.assign(n + 5, -1); } int find_set(int u) { return lab[u] < 0 ? u : lab[u] = find_set(lab[u]); } int sz(int u) { return -lab[find_set(u)]; } bool check(int a, int b) { a = find_set(a); b = find_set(b); return a == b ? true : false; } bool unite(int a, int b) { a = find_set(a); b = find_set(b); if(a == b) return false; if(lab[a] > lab[b]) swap(a, b); lab[a] += lab[b]; lab[b] = a; return true; } } dsu; struct Circle { int x, y, r; Circle() {x = y = r = 0;} Circle(int x_, int y_, int r_) : x(x_), y(y_), r(r_) {} } a[N]; int n, m, w, h; vector<tuple<int, int, int>>edge, event; vector<pair<int, int>>v[5][5]; string res[N]; ll square(ll x) { return x * x; } int dist(Circle x, Circle y) { //cout << x.x << ' ' << x.y << ' ' << y.x << ' ' << y.y << '\n'; //cout << sqrt(square(x.x - y.x) + square(x.y - y.y)) << ' ' << x.r << ' ' << y.r << '\n'; return sqrt(square(x.x - y.x) + square(x.y - y.y)) - x.r - y.r; } int main() { fastio; local(); cin >> n >> m >> w >> h; for(int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y >> a[i].r; for(int i = 1; i <= n; i++) { for(int j = i + 1; j <= n; j++) { edge.emplace_back(dist(a[i], a[j]), i, j); } } for(int i = 1; i <= n; i++) { edge.emplace_back(dist(a[i], Circle(a[i].x, 0, 0)), i, n + 1); edge.emplace_back(dist(a[i], Circle(0, a[i].y, 0)), i, n + 2); edge.emplace_back(dist(a[i], Circle(a[i].x, h, 0)), i, n + 3); edge.emplace_back(dist(a[i], Circle(w, a[i].y, 0)), i, n + 4); } for(int i = 1; i <= m; i++) { int r, e; cin >> r >> e; event.emplace_back(r, e, i); } dsu.init(n + 4); for(int i = 1; i < 5; i++) { for(int j = 1; j < 5; j++) { if(i == j) continue; if(i == 1) v[i][j].emplace_back(n + 2, n + 1); if(i == 2) v[i][j].emplace_back(n + 1, n + 4); if(i == 3) v[i][j].emplace_back(n + 4, n + 3); if(i == 4) v[i][j].emplace_back(n + 3, n + 2); } v[i][(i + 1) % 4 + 1].emplace_back(n + 1, n + 3); v[i][(i + 1) % 4 + 1].emplace_back(n + 2, n + 4); if(i & 1) { v[i][(i + 1) % 4 + 1].emplace_back(n + 1, n + 3); v[i][(i + 2) % 4 + 1].emplace_back(n + 2, n + 4); } else { v[i][(i + 1) % 4 + 1].emplace_back(n + 2, n + 4); v[i][(i + 2) % 4 + 1].emplace_back(n + 1, n + 3); } } sort(edge.begin(), edge.end()); sort(event.begin(), event.end()); int pter = 0; for(tuple<int, int, int> t : event) { int r, e, id; tie(r, e, id) = t; while(pter < edge.size() && 2 * r > get<0>(edge[pter])) { dsu.unite(get<1>(edge[pter]), get<2>(edge[pter])); pter++; } for(int j = 1; j < 5; j++) { bool ok = true; for(pair<int, int>p : v[e][j]) { if(dsu.check(p.first, p.second)) ok = false; } for(pair<int, int>p : v[j][e]) { if(dsu.check(p.first, p.second)) ok = false; } if(ok) res[id] += char(j + '0'); } } for(int i = 1; i <= m; i++) cout << res[i] << '\n'; }

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

park.cpp: In function 'int main()':
park.cpp:106:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |      while(pter < edge.size() && 2 * r > get<0>(edge[pter])) {
      |            ~~~~~^~~~~~~~~~~~~
park.cpp: In function 'void local()':
park.cpp:7:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
park.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...