Submission #829853

# Submission time Handle Problem Language Result Execution time Memory
829853 2023-08-18T15:23:34 Z FatihSolak Circle selection (APIO18_circle_selection) C++17
7 / 100
3000 ms 36892 KB
#include <bits/stdc++.h>
#define N 300005
using namespace std;
int x[N],y[N],c[N];
int ans[N];
int t[N];
void solve(){
    int n;
    cin >> n;
    vector<int> ord;
    for(int i = 1;i<=n;i++){
        cin >> x[i] >> y[i] >> c[i];
        ord.push_back(i);
    }
    sort(ord.begin(),ord.end(),[&](int a,int b){
        if(c[a] == c[b])
            return a < b;
        return c[a] > c[b];
    });
    set<pair<long long,int>> s[3][3][3];
    set<int> alive;
    int cnt = 0;
    for(auto u:ord){
        int num = -1;
        vector<int> cand;
        for(auto xx:alive)
            cand.push_back(xx);
        // for(int i = -1;i<=1;i++){
        //     for(int j = -1;j<=1;j++){
        //         for(int k = -1;k<=1;k++){
        //             long long sum = 0;
        //             sum += i * x[u];
        //             sum += j * y[u];
        //             sum += k * c[u];
        //             auto it = s[i + 1][j + 1][k + 1].lower_bound({sum,0});
        //             if(it != s[i+1][j+1][k+1].end()){
        //                 cand.push_back(it->second);
        //             }
        //             if(it != s[i+1][j+1][k+1].begin()){
        //                 cand.push_back(prev(it)->second);
        //             }
        //         }
        //     }
        // }
        for(auto cc:cand){
            long long val1 = (long long)(c[u] + c[cc]) *(c[u] + c[cc]);
            long long val2 =  (long long)(x[u] - x[cc]) *(x[u] - x[cc])
            + (long long)(y[u] - y[cc]) *(y[u] - y[cc]);
            if(val2 <= val1){
                if(num == -1 || t[u] < t[num])
                    num = cc;
            }
        }
        if(num == -1){
            alive.insert(u);
            t[u] =cnt++;
            ans[u] = u;
            for(int i = -1;i<=1;i++){
                for(int j = -1;j<=1;j++){
                    for(int k = -1;k<=1;k++){
                        long long sum = 0;
                        sum += i * x[u];
                        sum += j * y[u];
                        sum += k * c[u];
                        s[i + 1][j + 1][k + 1].insert({sum,u});
                    }
                }
            }
        }
        else ans[u] = num;
    }
    for(int i = 1;i<=n;i++){
        cout << ans[i] << ' ';
    }
}
    
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifdef Local    
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 416 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 264 ms 9232 KB Output is correct
23 Correct 255 ms 9200 KB Output is correct
24 Correct 283 ms 9200 KB Output is correct
25 Correct 294 ms 9228 KB Output is correct
26 Correct 301 ms 9272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 123 ms 8504 KB Output is correct
2 Incorrect 141 ms 8388 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 3054 ms 25424 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3096 ms 36892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 416 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 264 ms 9232 KB Output is correct
23 Correct 255 ms 9200 KB Output is correct
24 Correct 283 ms 9200 KB Output is correct
25 Correct 294 ms 9228 KB Output is correct
26 Correct 301 ms 9272 KB Output is correct
27 Incorrect 7 ms 596 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 416 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 264 ms 9232 KB Output is correct
23 Correct 255 ms 9200 KB Output is correct
24 Correct 283 ms 9200 KB Output is correct
25 Correct 294 ms 9228 KB Output is correct
26 Correct 301 ms 9272 KB Output is correct
27 Correct 123 ms 8504 KB Output is correct
28 Incorrect 141 ms 8388 KB Output isn't correct
29 Halted 0 ms 0 KB -