답안 #49134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49134 2018-05-22T15:46:38 Z BThero 원 고르기 (APIO18_circle_selection) C++17
0 / 100
3000 ms 40148 KB
// Why am I so stupid? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

typedef long long ll;

using namespace std;

struct circle {
    int x, y, r;

    circle() {
        x = y = r = 0;
    }
} arr[300005];

map < pair <int, int>, vector <int> > mm;

int ans[300005];

int n;

bool inter(circle a, circle b) {
    ll dist = (a.x - b.x) * 1ll * (a.x - b.x) + (a.y - b.y) * 1ll * (a.y - b.y);
    return dist <= a.r + b.r;
}

void solve() {
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r);
    }

    int R = arr[1].r;

    for (int i = 1; i <= n; ++i) {
        mm[mp(arr[i].x / R, arr[i].y / R)].pb(i);
        ans[i] = i;
    }

    for (int i = 1; i <= n; ++i) {
        if (ans[i] != i) {
            continue;
        }

        int cx = arr[i].x / R, cy = arr[i].y / R;

        for (int x = cx - 2; x <= cx + 2; ++x) {
            for (int y = cy - 2; y <= cy + 2; ++y) {
                if (mm.find(mp(x, y)) == mm.end()) {
                    continue;
                }

                for (int it : mm[mp(x, y)]) {
                    if (inter(arr[i], arr[it])) {
                        ans[it] = i;
                    }
                }
            }
        }
    }

    for (int i = 1; i <= n; ++i) {
        printf("%d ", ans[i]);
    }
}

int main() {
#ifdef BThero
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // BThero

    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Compilation message

circle_selection.cpp: In function 'void solve()':
circle_selection.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
circle_selection.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3832 KB Output is correct
2 Correct 5 ms 3832 KB Output is correct
3 Incorrect 6 ms 3996 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3062 ms 6612 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 6612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2016 ms 40148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3832 KB Output is correct
2 Correct 5 ms 3832 KB Output is correct
3 Incorrect 6 ms 3996 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3832 KB Output is correct
2 Correct 5 ms 3832 KB Output is correct
3 Incorrect 6 ms 3996 KB Output isn't correct
4 Halted 0 ms 0 KB -