# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1105992 |
2024-10-28T16:13:38 Z |
doducanh |
Park (BOI16_park) |
C++14 |
|
613 ms |
89432 KB |
///breaker
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define double long double
#define fi first
#define se second
#define ii pair<int,int>
#define mp make_pair
#define in(x) freopen(x,"r",stdin)
#define out(x) freopen(x,"w",stdout)
#define bit(x,i) ((x>>i)&1)
#define lc (id<<1)
#define rc ((id<<1)^1)
const int maxn=4005;
const int maxm=1e5+7;
int sz[2*maxm];
int r[2*maxm];
bool ok[maxm][4];
struct tree
{
int fi,se,r;
}a[maxn];
struct nguoi
{
int id,r,e;
}b[maxm];
struct edges
{
ll dodai;
ii a,b;
bool operator <(const edges &b){
return dodai<b.dodai;
}
};
int n,m,w,h;
vector<edges>ed;
long long dis(int x1,int y1,int x2,int y2)
{
return sqrt(1ll*(x2-x1)*(x2-x1)+1ll*(y2-y1)*(y2-y1));
}
void add(int x1,int y1,int x2,int y2,int r1,int r2)
{
long long dist=dis(x1,y1,x2,y2)-r1-r2;
ii a={x1,y1};
ii b={x2,y2};
ed.push_back({dist,a,b});
}
int Find(int u)
{
return ((u==r[u])?u:r[u]=Find(r[u]));
}
map<ii,int>cc;
bool ans[maxm][4];
void Union(int a,int b)
{
a=Find(a);
b=Find(b);
if(a==b)return;
if(sz[a]<sz[b])swap(a,b);
sz[a]+=sz[b];
r[b]=a;
}
void sol(void){
cin>>n>>m;
cin>>w>>h;
for(int i=1;i<=n;i++){
cin>>a[i].fi>>a[i].se>>a[i].r;
cc[(ii){0,a[i].se}]=3;
cc[(ii){a[i].fi,h}]=2;
cc[(ii){w,a[i].se}]=1;
cc[(ii){a[i].fi,0}]=0;
add(a[i].fi,a[i].se,0,a[i].se,a[i].r,0);
add(a[i].fi,a[i].se,a[i].fi,h,a[i].r,0);
add(a[i].fi,a[i].se,w,a[i].se,a[i].r,0);
add(a[i].fi,a[i].se,a[i].fi,0,a[i].r,0);
}
int cnt=4;
for(int i=1;i<=n;i++){
cc[(ii){a[i].fi,a[i].se}]=cnt++;
for(int j=i+1;j<=n;j++){
add(a[i].fi,a[i].se,a[j].fi,a[j].se,a[i].r,a[j].r);
}
}
for(int i=0;i<=maxn;i++){
r[i]=i;
sz[i]=1;
}
for(int i=1;i<=m;i++){
cin>>b[i].r>>b[i].e;
b[i].e--;
b[i].r=2*b[i].r;
b[i].id=i;
}
sort(b+1,b+m+1,[&](const nguoi &a,const nguoi &b){
return a.r<b.r;
});
for(int i=1;i<=m;i++){
for(int j=0;j<4;j++){
ok[i][j]=1;
}
}
sort(ed.begin(),ed.end());
int p=1;
for(auto v:ed){
while(p<=m&&(double)b[p].r<=(double)v.dodai){
nguoi curr=b[p];
bool con[4][4];
for(int i=0;i<4;i++){
con[i][i]=true;
for(int j=i+1;j<4;j++){
con[i][j]=(Find(i)==Find(j));
con[j][i]=con[i][j];
}
}
auto check=[&](int x){return con[x][((x-1<0)?3:x-1)];};
for(int i=0;i<4;i++){
if(curr.e==i)continue;
if(check(curr.e)||check(i)){
ok[curr.id][i]=0;
continue;
}
bool ngang=con[1][3];
bool doc=con[0][2];
if(curr.e+i==3){
if(ngang){
ok[curr.id][i]=0;
continue;
}
}
else if(abs(curr.e-i)==2){
if(doc||ngang){
ok[curr.id][i]=0;
continue;
}
}
else if(doc){
ok[curr.id][i]=0;
continue;
}
}
p++;
}
Union(cc[v.a],cc[v.b]);
}
for(int i=1;i<=m;i++){
for(int j=0;j<4;j++){
if(ok[i][j]){
cout<<j+1;
}
}
cout<<"\n";
}
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t=1;
while(t--){
sol();
}
// you should actually read the stuff at the bottom
return 0;
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/
//5 3
//16 11
//11 8 1
//6 10 1
//7 3 2
//10 4 1
//15 5 1
//1 1
//2 2
//2 1
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
545 ms |
89040 KB |
Output is correct |
2 |
Correct |
521 ms |
89040 KB |
Output is correct |
3 |
Correct |
523 ms |
89040 KB |
Output is correct |
4 |
Correct |
525 ms |
89080 KB |
Output is correct |
5 |
Correct |
519 ms |
89040 KB |
Output is correct |
6 |
Correct |
529 ms |
89196 KB |
Output is correct |
7 |
Correct |
494 ms |
88776 KB |
Output is correct |
8 |
Correct |
472 ms |
89036 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
1 ms |
6480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
7908 KB |
Output is correct |
2 |
Correct |
33 ms |
7908 KB |
Output is correct |
3 |
Correct |
41 ms |
8836 KB |
Output is correct |
4 |
Correct |
34 ms |
8924 KB |
Output is correct |
5 |
Correct |
35 ms |
8932 KB |
Output is correct |
6 |
Correct |
37 ms |
8928 KB |
Output is correct |
7 |
Correct |
30 ms |
8016 KB |
Output is correct |
8 |
Correct |
28 ms |
8016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
545 ms |
89040 KB |
Output is correct |
2 |
Correct |
521 ms |
89040 KB |
Output is correct |
3 |
Correct |
523 ms |
89040 KB |
Output is correct |
4 |
Correct |
525 ms |
89080 KB |
Output is correct |
5 |
Correct |
519 ms |
89040 KB |
Output is correct |
6 |
Correct |
529 ms |
89196 KB |
Output is correct |
7 |
Correct |
494 ms |
88776 KB |
Output is correct |
8 |
Correct |
472 ms |
89036 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
1 ms |
6480 KB |
Output is correct |
11 |
Correct |
35 ms |
7908 KB |
Output is correct |
12 |
Correct |
33 ms |
7908 KB |
Output is correct |
13 |
Correct |
41 ms |
8836 KB |
Output is correct |
14 |
Correct |
34 ms |
8924 KB |
Output is correct |
15 |
Correct |
35 ms |
8932 KB |
Output is correct |
16 |
Correct |
37 ms |
8928 KB |
Output is correct |
17 |
Correct |
30 ms |
8016 KB |
Output is correct |
18 |
Correct |
28 ms |
8016 KB |
Output is correct |
19 |
Correct |
613 ms |
89288 KB |
Output is correct |
20 |
Correct |
598 ms |
89296 KB |
Output is correct |
21 |
Correct |
568 ms |
89292 KB |
Output is correct |
22 |
Correct |
559 ms |
89288 KB |
Output is correct |
23 |
Correct |
562 ms |
89432 KB |
Output is correct |
24 |
Correct |
486 ms |
89040 KB |
Output is correct |