Submission #103296

# Submission time Handle Problem Language Result Execution time Memory
103296 2019-03-29T17:23:42 Z pavel Park (BOI16_park) C++14
0 / 100
323 ms 33500 KB
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<int,int> ii;

const int MAXN = 2010;
const int MAXM = 100005;

struct edge{
    double 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){
            double d = sqrt((double)(x[i]-x[j])*(x[i]-x[j])+(double)(y[i]-y[j])*(y[i]-y[j]));
            e.emplace_back(i, j, d-r[i]-r[j]);
        }
        e.emplace_back(i, n, (double)x[i]-r[i]);
        e.emplace_back(i, n+1, (double)y[i]-r[i]);
        e.emplace_back(i, n+2, (double)w-x[i]-r[i]);
        e.emplace_back(i, n+3, (double)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 >= 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;
            }
        }
        char* s = sol[q[i].second];
        for(int j=0;j<4;++j){
            if(c[start[q[i].second]][j]){
                s+=sprintf(s, "%d", j+1);
            }
        }
    }
    for(int i=0;i<m;++i){
        puts(sol[i]);
    }
}

Compilation message

park.cpp: In function 'int main()':
park.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d", &n, &m, &w, &h);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
park.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &x[i], &y[i], &r[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
park.cpp:63:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &q[i].first, &start[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 306 ms 33340 KB Output is correct
2 Correct 323 ms 33340 KB Output is correct
3 Correct 270 ms 33340 KB Output is correct
4 Correct 291 ms 33340 KB Output is correct
5 Correct 292 ms 33340 KB Output is correct
6 Correct 266 ms 33280 KB Output is correct
7 Correct 306 ms 33500 KB Output is correct
8 Incorrect 253 ms 33356 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 306 ms 33340 KB Output is correct
2 Correct 323 ms 33340 KB Output is correct
3 Correct 270 ms 33340 KB Output is correct
4 Correct 291 ms 33340 KB Output is correct
5 Correct 292 ms 33340 KB Output is correct
6 Correct 266 ms 33280 KB Output is correct
7 Correct 306 ms 33500 KB Output is correct
8 Incorrect 253 ms 33356 KB Output isn't correct
9 Halted 0 ms 0 KB -