This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma")
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int , int> pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 1e5 + 100;
const ll mod = 1e9+7;
const ld PI = acos((ld)-1);
#define pb push_back
#define endl '\n'
#define dokme(x) cout << x , exit(0)
#define migmig ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(x , y) memset(x , y , sizeof x)
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}
int n , m , w[2];
int pos[maxn][2] , r[maxn] , par[maxn] , ans[maxn][5];
vector < pair < int , pii > > vec;
int getpar(int v){
return((par[v] == -1) ? v : par[v] = getpar(par[v]));
}
int32_t main(){
migmig;
ms(par, -1);
cin >> n >> m >> w[0] >> w[1];
for(int i = 0 ; i < n ; i ++){
cin >> pos[i][0] >> pos[i][1] >> r[i];
for(int j = 0 ; j < i ; j ++){
ll d = 0;
for(int k = 0 ; k < 2 ; k ++) d += ((ll)pos[i][k] - pos[j][k])*((ll)pos[i][k] - pos[j][k]);
vec.pb({(int)sqrt(d) - r[i] - r[j] , {j , i}});
}
for(int j = 0 ; j < 2 ; j ++) for(int k = 0 ; k < 2 ; k ++)
vec.pb({abs(k * w[j] - pos[i][j]) - r[i] , {i , n + j + 2*k}});
}
for(int i = 0 ; i < m ; i ++){
int q , x;
cin >> q >> x;
vec.pb({2*q , {-x, i}});
}
sort(vec.begin() , vec.end());
/*
⠄⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄
⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄
⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄
⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰
⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗
⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠄
⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠄
⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃⠄
⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃⠄⠄
⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁⠄⠄⠄
⠄⠄⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁⠄⠄⠄⠄⠄⢀⣠⣴
⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣠
*/
for(auto [f , s] : vec){
if(s.first < 0){
for(int i = 0 , j = -s.first-1 ; i < 4 ; i ++){
ans[s.second][i] = 1;
if(i == j)continue;
ans[s.second][i] &= (getpar(n + j) != getpar(n + (j + 1)%4));
ans[s.second][i] &= (getpar(n + i) != getpar(n + (i + 1)%4));
ans[s.second][i] &= ((i - j + 4)%4 == 1) or (getpar(n + j) != getpar(n + (j + 2)%4));
ans[s.second][i] &= ((i - j + 4)%4 == 3) or (getpar(n + (j + 1)%4) != getpar(n + (j + 3)%4));
}
}
else{
int a = getpar(s.first) , b = getpar(s.second);
if(a ^ b)par[a] = b;
}
}
for(int i = 0 ; i < m ; i ++){
string res = "";
for(int j = 0 ; j < 4 ; j ++)if(ans[i][j])res += char('1' + j);
cout << res << endl;
}
return(0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |