# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
56901 | leejseo | 원 고르기 (APIO18_circle_selection) | C++98 | 172 ms | 27108 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
inline long long sq(long long x) { return x * x; }
typedef struct Circle{
int x, y;
int r;
int i;
Circle(int i_, int x_, int y_, int r_){ i = i_, x = x_, y = y_, r = r_; }
bool meet(const Circle &c) const{
return (sq((long long) (x - c.x)) + sq((long long) (y - c.y)) <= sq((long long) (r + c.r)));
}
bool operator < (const Circle &c) const{
if (r != c.r) return r > c.r;
return i < c.i;
}
} Circle;
vector<Circle> L;
int ans[300000];
bool vis[300000];
int N;
int input(){
scanf("%d", &N);
int minr = 1<<30;
int maxr = -1;
bool ally0 = 1;
int x, y, r;
for (int i=0; i<N; i++){
scanf("%d%d%d", &x, &y, &r);
L.push_back(Circle(i, x, y, r));
minr = min(minr, r);
maxr = max(maxr, r);
if (y != 0) ally0 = 0;
}
if (N <= 5000) return 1;
if (ally0) return 2;
if (minr == maxr) return 4;
return 3; // we skip sub5/6 we assume sub3
}
void sub1(){
sort(L.begin(), L.end());
for (int i=0; i<N; i++){
if (vis[i]) continue;
int ind = L[i].i;
ans[ind] = ind;
vis[i] = 1;
for (int j=0; j<N; j++){
if (vis[j]) continue;
if (L[i].meet(L[j])){
ans[L[j].i] = ind;
vis[j] = 1;
}
}
}
}
int main(void){
int st = input();
if (st == 1){
sub1();
for (int i=0; i<N; i++){
printf("%d ", ans[i]+1);
}
printf("\n");
}
else{
printf("-1");
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |