답안 #382132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
382132 2021-03-26T13:00:55 Z mohamedsobhi777 원 고르기 (APIO18_circle_selection) C++14
7 / 100
3000 ms 13260 KB
#include <bits/stdc++.h>

using namespace std;

#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define loop(_) for (int __ = 0; __ < (_); ++__)
#define pb push_back
#define f first
#define s second
#define sz(_) ((int)_.size())
#define all(_) _.begin(), _.end()
#define lb lower_bound
#define ub upper_bound

using ll = long long;
using ld = long double;

const int N = 1e5 + 7;
const ll mod = 1e9 + 7;

int n;
bool act[N];

struct circle
{
       int x, y, r, j;
       circle(int _x, int _y, int _r) : x(_x), y(_y), r(_r) {}
       bool operator<(circle &ohs)
       {
              return make_pair(-r, j) < make_pair(-ohs.r, ohs.j);
       }
       bool intersect(circle ohs)
       {
              double dist = hypot(x - ohs.x, y - ohs.y);
              double rr = r + ohs.r;
              return dist <= rr;
       }
};

int main()
{
       ios_base::sync_with_stdio(0);
       cin.tie(0);
#ifndef ONLINE_JUDGE
#endif
       cin >> n;

       vector<circle> v;

       for (int i = 0; i < n; ++i)
       {
              int x, y, r;
              cin >> x >> y >> r;
              v.pb(circle(x, y, r));
              v.back().j = i;
       }

       sort(all(v));
       vi ans(n);

       for (int i = 0; i < n; ++i)
       {
              if (act[i])
                     continue;
              ans[v[i].j] = v[i].j + 1;
              act[i] = 1;
              for (int j = 0; j < n; ++j)
              {
                     if (i == j)
                            continue;
                     if (!act[j] && v[i].intersect(v[j]))
                     {
                            ans[v[j].j] = v[i].j + 1;
                            act[j] = 1;
                     }
              }
       }

       for (auto u : ans)
              cout << u << " ";
       return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 5 ms 620 KB Output is correct
20 Correct 4 ms 620 KB Output is correct
21 Correct 4 ms 620 KB Output is correct
22 Correct 311 ms 620 KB Output is correct
23 Correct 296 ms 620 KB Output is correct
24 Correct 353 ms 620 KB Output is correct
25 Correct 404 ms 620 KB Output is correct
26 Correct 316 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 154 ms 13260 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 3063 ms 2664 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3077 ms 8668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 5 ms 620 KB Output is correct
20 Correct 4 ms 620 KB Output is correct
21 Correct 4 ms 620 KB Output is correct
22 Correct 311 ms 620 KB Output is correct
23 Correct 296 ms 620 KB Output is correct
24 Correct 353 ms 620 KB Output is correct
25 Correct 404 ms 620 KB Output is correct
26 Correct 316 ms 620 KB Output is correct
27 Correct 7 ms 752 KB Output is correct
28 Correct 7 ms 752 KB Output is correct
29 Correct 7 ms 748 KB Output is correct
30 Correct 1205 ms 752 KB Output is correct
31 Correct 1597 ms 752 KB Output is correct
32 Correct 1292 ms 952 KB Output is correct
33 Correct 61 ms 3044 KB Output is correct
34 Correct 63 ms 3044 KB Output is correct
35 Correct 71 ms 3244 KB Output is correct
36 Execution timed out 3083 ms 2536 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 5 ms 620 KB Output is correct
20 Correct 4 ms 620 KB Output is correct
21 Correct 4 ms 620 KB Output is correct
22 Correct 311 ms 620 KB Output is correct
23 Correct 296 ms 620 KB Output is correct
24 Correct 353 ms 620 KB Output is correct
25 Correct 404 ms 620 KB Output is correct
26 Correct 316 ms 620 KB Output is correct
27 Runtime error 154 ms 13260 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -