# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
39789 | 2018-01-18T16:23:25 Z | nonocut | Park (BOI16_park) | C++14 | 314 ms | 55236 KB |
#include<bits/stdc++.h> using namespace std; struct point { double x, y, r; }; struct quest { int id, e; double r; }; int n,m; double H,W; point p[2010]; quest q[100005]; vector<pair<double,pair<int,int> > > edge; int head[2010]; vector<int> ans[100005]; int findhead(int x) { if(x==head[x]) return x; return head[x] = findhead(head[x]); } bool cmp(quest a, quest b) { return a.r < b.r; } int main() { int i,j,x; double temp; scanf("%d%d%lf%lf",&n,&m,&W,&H); n += 4; for(i=5;i<=n;i++) scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].r); for(i=1;i<=m;i++) scanf("%lf%d",&q[i].r,&q[i].e), q[i].id = i; //point to point for(i=5;i<=n;i++) { for(j=i+1;j<=n;j++) { temp = (sqrt((p[i].x-p[j].x)*(p[i].x-p[j].x) + (p[i].y-p[j].y)*(p[i].y-p[j].y)) - p[i].r - p[j].r)/2.0; edge.push_back({temp, {i,j}}); // printf("point to point %d - %d is required at least %lf\n",i,j,temp); } } //point to edge for(i=5;i<=n;i++) { temp = p[i].x - p[i].r; edge.push_back({temp, {1,i}}); temp = p[i].y - p[i].r; edge.push_back({temp, {2,i}}); temp = (W - p[i].x) - p[i].r; edge.push_back({temp, {3,i}}); temp = (H - p[i].y) - p[i].r; edge.push_back({temp, {4,i}}); } sort(edge.begin(),edge.end()); sort(&q[1],&q[m+1],cmp); for(i=1;i<=n;i++) head[i] = i; for(i=1,j=0;i<=m;i++) { while(j<edge.size()) { if(edge[j].first>q[i].r) break; // printf("edge %d - %d\n",edge[j].second.first,edge[j].second.second); head[findhead(edge[j].second.first)] = findhead(edge[j].second.second); ++j; } // printf("------------------- quest %d\n",q[i].id); int block = findhead(q[i].e)==findhead(q[i].e%4 + 1); for(x=1;x<=4;x++) if((findhead(x)!=findhead(x%4 + 1) && !block) || q[i].e == x) ans[q[i].id].push_back(x); } for(i=1;i<=m;i++) { for(j=0;j<ans[i].size();j++) printf("%d",ans[i][j]); printf("\n"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 300 ms | 55236 KB | Output is correct |
2 | Correct | 314 ms | 55236 KB | Output is correct |
3 | Incorrect | 311 ms | 55236 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 105 ms | 9628 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 300 ms | 55236 KB | Output is correct |
2 | Correct | 314 ms | 55236 KB | Output is correct |
3 | Incorrect | 311 ms | 55236 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |