# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1073584 |
2024-08-24T16:20:01 Z |
Jarif_Rahman |
Park (BOI16_park) |
C++17 |
|
464 ms |
73008 KB |
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
typedef long double ld;
struct dsu{
int n;
vector<int> p, sz;
dsu(int _n): n(_n){
p.resize(n);
sz.resize(n, 1);
for(int i = 0; i < n; i++) p[i] = i;
}
int get(int x){
if(p[x] != x) p[x] = get(p[x]);
return p[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);
p[b] = a;
sz[a]+=sz[b];
sz[b] = 0;
}
bool same(int a, int b){
return get(a) == get(b);
}
};
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m; ld w, h; cin >> n >> m >> w >> h;
vector<tuple<ld, ld, ld>> circles(n);
vector<tuple<ld, int, int>> queries;
for(auto &[x, y, r]: circles) cin >> x >> y >> r;
for(int i = 0; i < m; i++){
ld r; int e; cin >> r >> e;
queries.push_back({r, e, i});
}
dsu ds(n+4);
vector<tuple<ld, int, int>> op;
for(int i = 0; i < n; i++){
auto [x1, y1, r1] = circles[i];
op.push_back({y1-r1, i, n});
op.push_back({w-x1-r1, i, n+1});
op.push_back({h-y1-r1, i, n+2});
op.push_back({x1-r1, i, n+3});
for(int j = i+1; j < n; j++){
auto [x2, y2, r2] = circles[j];
ld dis = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
dis = sqrt(dis);
op.push_back({dis-r1-r2, i, j});
}
}
sort(op.rbegin(), op.rend());
sort(queries.begin(), queries.end());
vector<pair<int, int>> sth[5][5];
sth[1][1] = {};
sth[1][2] = { {0,1}, {0,2}, {0,3} };
sth[1][3] = { {0,2}, {1,3}, {0,3}, {1,2} };
sth[1][4] = { {3,0}, {3,1}, {3,2} };
sth[2][1] = sth[1][2], sth[2][2] = {};
sth[2][3] = { {1,0}, {1,2}, {1,3} };
sth[2][4] = { {0,2}, {1,3}, {0,1}, {2,3} };
sth[3][1] = sth[1][3], sth[3][2] = sth[2][3], sth[3][3] = {};
sth[3][4] = { {2,0}, {2,1}, {2,3} };
sth[4][1] = sth[1][4], sth[4][2] = sth[2][4], sth[4][3] = sth[3][4], sth[4][4] = {};
vector<string> ans(m, "");
for(auto [r, e, in]: queries){
while(!op.empty() && get<0>(op.back()) < r*2.0){
auto [_, a, b] = op.back();
op.pop_back();
ds.unite(a, b);
}
for(int i = 1; i <= 4; i++){
bool ok = 1;
for(auto [a, b]: sth[e][i]) ok&=!ds.same(n+a, n+b);
if(ok) ans[in]+=('0'+i);
}
}
for(auto x: ans) cout << x << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
394 ms |
67248 KB |
Output is correct |
2 |
Correct |
422 ms |
68012 KB |
Output is correct |
3 |
Correct |
392 ms |
66512 KB |
Output is correct |
4 |
Correct |
397 ms |
66732 KB |
Output is correct |
5 |
Correct |
418 ms |
66756 KB |
Output is correct |
6 |
Correct |
405 ms |
67204 KB |
Output is correct |
7 |
Correct |
384 ms |
68288 KB |
Output is correct |
8 |
Correct |
380 ms |
66896 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
9920 KB |
Output is correct |
2 |
Correct |
51 ms |
9952 KB |
Output is correct |
3 |
Correct |
54 ms |
10128 KB |
Output is correct |
4 |
Correct |
49 ms |
10352 KB |
Output is correct |
5 |
Correct |
49 ms |
9920 KB |
Output is correct |
6 |
Correct |
52 ms |
10692 KB |
Output is correct |
7 |
Correct |
46 ms |
8128 KB |
Output is correct |
8 |
Correct |
45 ms |
8124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
394 ms |
67248 KB |
Output is correct |
2 |
Correct |
422 ms |
68012 KB |
Output is correct |
3 |
Correct |
392 ms |
66512 KB |
Output is correct |
4 |
Correct |
397 ms |
66732 KB |
Output is correct |
5 |
Correct |
418 ms |
66756 KB |
Output is correct |
6 |
Correct |
405 ms |
67204 KB |
Output is correct |
7 |
Correct |
384 ms |
68288 KB |
Output is correct |
8 |
Correct |
380 ms |
66896 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
50 ms |
9920 KB |
Output is correct |
12 |
Correct |
51 ms |
9952 KB |
Output is correct |
13 |
Correct |
54 ms |
10128 KB |
Output is correct |
14 |
Correct |
49 ms |
10352 KB |
Output is correct |
15 |
Correct |
49 ms |
9920 KB |
Output is correct |
16 |
Correct |
52 ms |
10692 KB |
Output is correct |
17 |
Correct |
46 ms |
8128 KB |
Output is correct |
18 |
Correct |
45 ms |
8124 KB |
Output is correct |
19 |
Correct |
442 ms |
72480 KB |
Output is correct |
20 |
Correct |
452 ms |
71824 KB |
Output is correct |
21 |
Correct |
463 ms |
72228 KB |
Output is correct |
22 |
Correct |
464 ms |
72552 KB |
Output is correct |
23 |
Correct |
449 ms |
71960 KB |
Output is correct |
24 |
Correct |
428 ms |
73008 KB |
Output is correct |