답안 #710058

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710058 2023-03-15T04:11:53 Z vjudge1 원 고르기 (APIO18_circle_selection) C++17
12 / 100
1025 ms 53124 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 3e5 + 10;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define ff first
#define ss second
int calc(ii x, ii y)
{
    return (x.ff-y.ff)*(x.ff-y.ff) + (x.ss-y.ss)*(x.ss-y.ss);
}
bool dau[maxn];
int res[maxn];
int n;
iii a[maxn];
int id[maxn];
int f[maxn];
void update(int x, int val)
{
    while (x<=n)
    {
        f[x] += val;
    }
}
multiset<ii> ms;
bool cmp(int x, int y)
{
    if (a[x].ss!=a[y].ss) return a[x].ss>a[y].ss;
    return x<y;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i].ff.ff>>a[i].ff.ss>>a[i].ss;
        ms.insert({a[i].ff.ff-a[i].ss,i});
        ms.insert({a[i].ff.ff+a[i].ss,i});
        dau[i]=0;
        id[i]=i;
    }
    sort(id+1,id+n+1,cmp);
    for (int i=1; i<=n; i++)
    {
        int j = id[i];
        if (dau[j]) continue;
        ii temp = {a[j].ff.ff - a[j].ss, -1};
        auto x = ms.lower_bound(temp);
        vector <int> tmp;
        while (x!=ms.end()&&(*x).ff <= a[j].ff.ff + a[j].ss)
        {
            int v = (*x).ss; x++;
            if (!dau[v])
            {
                dau[v] = 1;
                tmp.push_back(v);
            }
        }
        for (int u:tmp)
        {
            res[u] = j;
            ms.erase(ms.find({a[u].ff.ff-a[u].ss,u}));
            ms.erase(ms.find({a[u].ff.ff+a[u].ss,u}));
        }
    }
    for (int i=1; i<=n; i++) cout<<res[i]<<' '; cout<<'\n';
}
/**
11
9 0 2
13 0 1
11 0 2
3 0 2
3 0 1
12 0 1
9 0 1
2 0 2
5 0 1
14 0 2
14 0 1
**/

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:69:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   69 |     for (int i=1; i<=n; i++) cout<<res[i]<<' '; cout<<'\n';
      |     ^~~
circle_selection.cpp:69:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   69 |     for (int i=1; i<=n; i++) cout<<res[i]<<' '; cout<<'\n';
      |                                                 ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1016 ms 52460 KB Output is correct
2 Correct 1006 ms 53124 KB Output is correct
3 Correct 1025 ms 52644 KB Output is correct
4 Correct 953 ms 52356 KB Output is correct
5 Correct 724 ms 51792 KB Output is correct
6 Correct 665 ms 51832 KB Output is correct
7 Correct 693 ms 51840 KB Output is correct
8 Correct 629 ms 51796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 651 ms 51576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -