# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103308 | 2019-03-29T17:53:57 Z | pavel | Park (BOI16_park) | C++14 | 520 ms | 66164 KB |
#include <cstdio> #include <cmath> #include <algorithm> #include <vector> using namespace std; typedef pair<int,int> ii; typedef long double ld; const int MAXN = 2010; const int MAXM = 100005; struct edge{ ld w; int u,v; edge(int x, int y, int t){ u=x;v=y;w=t; } }; bool operator<(const edge& a, const edge& b){ return a.w < b.w; } int n,m,w,h; int x[MAXN],y[MAXN],r[MAXN]; int start[MAXN]; int uf[MAXN]; bool c[4][4]; char sol[MAXM][10]; int fnd(int x){ if(uf[x]==x) return x; return uf[x]=fnd(uf[x]); } void un(int a, int b){ uf[fnd(a)]=fnd(b); } vector<edge> e; vector<ii> q; int main(){ for(int i=0;i<4;++i) for(int j=0;j<4;++j) c[i][j]=true; for(int i=0;i<MAXN;++i) uf[i]=i; scanf("%d%d%d%d", &n, &m, &w, &h); for(int i=0;i<n;++i){ scanf("%d%d%d", &x[i], &y[i], &r[i]); for(int j=0;j<i;++j){ ld d = sqrt((ld)(x[i]-x[j])*(x[i]-x[j])+(ld)(y[i]-y[j])*(y[i]-y[j])); e.emplace_back(i, j, d-r[i]-r[j]); } e.emplace_back(i, n, (ld)x[i]-r[i]); e.emplace_back(i, n+1, (ld)y[i]-r[i]); e.emplace_back(i, n+2, (ld)w-x[i]-r[i]); e.emplace_back(i, n+3, (ld)h-y[i]-r[i]); } sort(e.begin(), e.end()); q.resize(m); for(int i=0;i<m;++i){ scanf("%d%d", &q[i].first, &start[i]); start[i]--; q[i].second=i; } sort(q.begin(), q.end()); auto it = e.begin(); for(int i=0;i<m;++i){ while(it!=e.end() && q[i].first*2 > round(it->w)){ un(it->u, it->v); it++; } if(fnd(n)==fnd(n+2)){ c[0][2]=c[0][3]=c[1][2]=c[1][3]=false; c[2][0]=c[3][0]=c[2][1]=c[3][1]=false; } if(fnd(n+1)==fnd(n+3)){ c[0][1]=c[0][2]=c[3][1]=c[3][2]=false; c[1][0]=c[2][0]=c[1][3]=c[2][3]=false; } for(int k=0;k<4;++k){ if(fnd(n+k)==fnd(n+(k+1)%4)){ for(int j=0;j<4;++j) if(k!=j) c[k][j]=c[j][k]=false; } } int si=0; for(int j=0;j<4;++j){ if(c[start[q[i].second]][j]){ sol[q[i].second][si++]='1'+j; } } } for(int i=0;i<m;++i){ puts(sol[i]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 483 ms | 66076 KB | Output is correct |
2 | Correct | 451 ms | 66072 KB | Output is correct |
3 | Correct | 441 ms | 66072 KB | Output is correct |
4 | Correct | 445 ms | 66072 KB | Output is correct |
5 | Correct | 473 ms | 66072 KB | Output is correct |
6 | Correct | 482 ms | 66148 KB | Output is correct |
7 | Correct | 454 ms | 66164 KB | Output is correct |
8 | Correct | 520 ms | 66072 KB | Output is correct |
9 | Correct | 2 ms | 356 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 1944 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 483 ms | 66076 KB | Output is correct |
2 | Correct | 451 ms | 66072 KB | Output is correct |
3 | Correct | 441 ms | 66072 KB | Output is correct |
4 | Correct | 445 ms | 66072 KB | Output is correct |
5 | Correct | 473 ms | 66072 KB | Output is correct |
6 | Correct | 482 ms | 66148 KB | Output is correct |
7 | Correct | 454 ms | 66164 KB | Output is correct |
8 | Correct | 520 ms | 66072 KB | Output is correct |
9 | Correct | 2 ms | 356 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Incorrect | 12 ms | 1944 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |