답안 #936527

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936527 2024-03-02T04:57:04 Z yellowtoad Park (BOI16_park) C++17
0 / 100
351 ms 67116 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#define f first
#define s second
using namespace std;

int n, m, w, h, p[2010], cur, can[100010][5];
pair<pair<int,int>,int> b[100010];
pair<int,pair<int,int>> a[2010];
vector<pair<long double,pair<int,int>>> edge;

int dsu(int u) {
    if (u == p[u]) return u;
    return (p[u] = dsu(p[u]));
}

int main() {
    cin >> n >> m >> w >> h;
    for (int i = 1; i <= n; i++) cin >> a[i].s.f >> a[i].s.s >> a[i].f;
    for (int i = 1; i <= n; i++) {
        for (int j = i+1; j <= n; j++) edge.push_back({(long double)sqrt((a[i].s.f-a[j].s.f)*(a[i].s.f-a[j].s.f)+(a[i].s.s-a[j].s.s)*(a[i].s.s-a[j].s.s))-a[i].f-a[j].f,{i,j}});
        edge.push_back({a[i].s.s-a[i].f,{i,n+1}});
        edge.push_back({w-a[i].s.f-a[i].f,{i,n+2}});
        edge.push_back({h-a[i].s.s-a[i].f,{i,n+3}});
        edge.push_back({a[i].s.f-a[i].f,{i,n+4}});
    }
    sort(edge.begin(),edge.end());
    for (int i = 1; i <= n+4; i++) p[i] = i;
    for (int i = 1; i <= m; i++) {
        cin >> b[i].f.f >> b[i].f.s;
        b[i].s = i;
    }
    sort(b+1,b+m+1);
    for (int i = 1; i <= m; i++) {
        while ((cur < edge.size()) && (edge[cur].f < b[i].f.f*2)) {
            p[dsu(edge[cur].s.f)] = p[dsu(edge[cur].s.s)];
            cur++;
        }
        for (int j = 1; j <= 4; j++) can[b[i].s][j] = 1;
        if (p[dsu(n+1)] == p[dsu(n+2)]) {
            if (b[i].f.s == 2) can[b[i].s][1] = can[b[i].s][3] = can[b[i].s][4] = 0;
            else can[b[i].s][2] = 0;
        }
        if (p[dsu(n+1)] == p[dsu(n+3)]) {
            if ((b[i].f.s == 2) || (b[i].f.s == 3)) can[b[i].s][1] = can[b[i].s][4] = 0;
            else can[b[i].s][3] = can[b[i].s][2] = 0;
        }
        if (p[dsu(n+1)] == p[dsu(n+4)]) {
            if (b[i].f.s == 1) can[b[i].s][2] = can[b[i].s][3] = can[b[i].s][4] = 0;
            else can[b[i].s][1] = 0;
        }
        if (p[dsu(n+2)] == p[dsu(n+3)]) {
            if (b[i].f.s == 3) can[b[i].s][1] = can[b[i].s][2] = can[b[i].s][4] = 0;
            else can[b[i].s][3] = 0;
        }
        if (p[dsu(n+2)] == p[dsu(n+4)]) {
            if ((b[i].f.s == 1) || (b[i].f.s == 2)) can[b[i].s][3] = can[b[i].s][4] = 0;
            else can[b[i].s][1] = can[b[i].s][2] = 0;
        }
        if (p[dsu(n+3)] == p[dsu(n+4)]) {
            if (b[i].f.s == 4) can[b[i].s][1] = can[b[i].s][2] = can[b[i].s][3] = 0;
            else can[b[i].s][4] = 0;
        }
    }
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= 4; j++) if (can[i][j]) cout << j;
        cout << endl;
    }
}

Compilation message

park.cpp: In function 'int main()':
park.cpp:37:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long double, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         while ((cur < edge.size()) && (edge[cur].f < b[i].f.f*2)) {
      |                 ~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 351 ms 67116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 171 ms 4812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 351 ms 67116 KB Output isn't correct
2 Halted 0 ms 0 KB -