Submission #744533

# Submission time Handle Problem Language Result Execution time Memory
744533 2023-05-18T17:00:22 Z Abito Circle selection (APIO18_circle_selection) C++14
12 / 100
1389 ms 98408 KB
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define ep insert
#define pow pwr
#define sqrt sqrtt
#define elif else if
#define y1 YONE
#define int long long
using namespace std;
const int N=1e6+5;
int n,ans[N];
pair<pair<int,int>,int> a[N];
vector<int> adj[N];
map<int,int> mp;
bool cmp(pair<pair<int,int>,int> x,pair<pair<int,int>,int> y){
    if (x.F.S-x.F.F!=y.F.S-y.F.F) return x.F.S-x.F.F>y.F.S-y.F.F;
    return x.S<y.S;
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n;
    for (int i=1;i<=n;i++){
        int x,y,r;
        cin>>x>>y>>r;
        a[i]={{x-r,x+r},i};
        mp[x+r]++;
        mp[x-r]++;
    }
    sort(a+1,a+1+n,cmp);
    int c=0;
    for (auto u:mp){
        c++;
        mp[u.F]=c;
    }
    for (int i=1;i<=n;i++){
        a[i].F={mp[a[i].F.F],mp[a[i].F.S]};
        adj[a[i].F.F].pb(i);
        adj[a[i].F.S].pb(i);
    }
    for (int i=1;i<=n;i++){
        if (ans[a[i].S]) continue;
        for (int j=a[i].F.F;j<=a[i].F.S;j++){
            for (auto u:adj[j]){
                if (!ans[a[u].S]) ans[a[u].S]=a[i].S;
            }adj[j].clear();
        }
    }
    for (int i=1;i<=n;i++) cout<<ans[i]<<' ';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Incorrect 14 ms 23772 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1327 ms 96044 KB Output is correct
2 Correct 1370 ms 98408 KB Output is correct
3 Correct 1297 ms 98024 KB Output is correct
4 Correct 1389 ms 98336 KB Output is correct
5 Correct 997 ms 68536 KB Output is correct
6 Correct 1008 ms 95184 KB Output is correct
7 Correct 1185 ms 89972 KB Output is correct
8 Correct 1062 ms 92504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1137 ms 93692 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Incorrect 14 ms 23772 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Incorrect 14 ms 23772 KB Output isn't correct
4 Halted 0 ms 0 KB -