# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
113335 |
2019-05-25T06:08:40 Z |
Mahdi_Jfri |
Park (BOI16_park) |
C++14 |
|
612 ms |
258000 KB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ld long double
const int maxn = 2e3 + 20;
const int maxm = maxn * maxn + 20;
int x[maxn] , y[maxn] , r[maxn] , e[maxn] , par[maxn] , n;
vector<int> query[maxm];
string res[maxm / 4];
int root(int v)
{
return (par[v] < 0? v : par[v] = root(par[v]));
}
bool cn(int a , int b)
{
a %= 4 , b %= 4;
a += n , b += n;
a = root(a) , b = root(b);
return (a == b);
}
void merge(int a , int b)
{
a = root(a) , b = root(b);
if(a != b)
par[b] = a;
}
ld d(int i , int j)
{
return sqrt(1LL * (x[i] - x[j]) * (x[i] - x[j]) + 1LL * (y[i] - y[j]) * (y[i] - y[j]));
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
memset(par , -1 , sizeof par);
int m , w , h;
cin >> n >> m >> w >> h;
for(int i = 0; i < n; i++)
cin >> x[i] >> y[i] >> r[i];
vector<pair<ld , pair<int , int> > > edge;
for(int i = 0; i < n; i++)
{
for(int j = i + 1; j < n; j++)
{
ld w = (d(i , j) - r[i] - r[j]) / 2;
edge.pb({w , {i , j}});
}
{
ld w = y[i] / 2.0;
edge.pb({w , {i , n}});
}
{
ld w = x[i] / 2.0;
edge.pb({w , {i , n + 3}});
}
{
ld w = (h - y[i]) / 2.0;
edge.pb({w , {i , n + 2}});
}
{
ld w1 = (w - x[i]) / 2.0;
edge.pb({w1 , {i , n + 1}});
}
}
sort(edge.begin() , edge.end());
for(int i = 0; i < m; i++)
{
int r;
cin >> r >> e[i];
e[i]--;
pair<ld , pair<int , int> > tmp = {r , {maxn , maxn}};
int k = lower_bound(edge.begin() , edge.end() , tmp) - edge.begin() - 1;
query[k].pb(i);
}
for(int i = 0; i < (int)edge.size(); i++)
{
merge(edge[i].second.first , edge[i].second.second);
for(auto ind : query[i])
{
res[ind] = e[ind] + '1';
int val = e[ind];
// 1
if(!cn(val , val + 1) && !cn(val , val + 2) && !cn(val , val + 3))
res[ind] += e[ind] + '1' + 1;
// 2
if(!cn(val , val + 3) && !cn(val , val + 2) && !cn(val + 1 , val + 2) && !cn(val + 1 , val + 3))
res[ind] += e[ind] + '1' + 2;
// 3
if(!cn(val + 3 , val) && !cn(val + 3 , val + 1) && !cn(val + 3 , val + 2))
res[ind] += e[ind] + '1' + 3;
}
}
for(int i = 0; i < m; i++)
{
sort(res[i].begin() , res[i].end());
cout << res[i] << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
612 ms |
193948 KB |
Output is correct |
2 |
Incorrect |
599 ms |
194084 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
231 ms |
258000 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
612 ms |
193948 KB |
Output is correct |
2 |
Incorrect |
599 ms |
194084 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |