Submission #982340

# Submission time Handle Problem Language Result Execution time Memory
982340 2024-05-14T07:03:56 Z Muhammad_Aneeq Circle selection (APIO18_circle_selection) C++17
7 / 100
3000 ms 38960 KB
/*
بسم الله الرحمن الرحيم
Author:
                          (:Muhammad Aneeq:)
*/

#include <iostream>
#include <set>
#include <vector>
using namespace std;
#define int long long
int man(pair<int,int>a,pair<int,int>b)
{
    return ((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}
inline void solve()
{
    int n;
    cin>>n;
    pair<int,int>a[n];
    bool w=0;
    set<pair<int,int>>s;
    for (int i=0;i<n;i++)
    {
        int x,y,r;
        cin>>x>>y>>r;
        a[i]={x,y};
        if (y!=0)
            w=1;
        s.insert({-r,i});
    }  
    if (w==0)
    {
        bool vis[n]={};
        int ans[n]={};
        while (s.size())
        {
            int r=(*begin(s)).first,i=(*begin(s)).second;
            s.erase(*begin(s));
            ans[i]=i;
            vis[i]=1;
            vector<pair<int,int>>z;
            for (int j=i+1;j<n;j++)
            {
                if (vis[j])
                    break;
                int r1=a[j].first;
                int dis=man(a[i],a[j]);
                if (dis<=((r+r1)*(r+r1)))
                    z.push_back({r1,j});
            }
            for (int j=i-1;j>=0;j--)
            {
                if (vis[j])
                    break;
                int r1=a[j].first;
                int dis=man(a[i],a[j]);
                if (dis<=((r+r1)*(r+r1)))
                    z.push_back({r1,j});
            }
            for (auto j:z)
            {
                ans[j.second]=i;
                vis[j.second]=1;
                s.erase(j);
            }
        }
        for (auto i:ans)
            cout<<i<<' ';
        cout<<endl;
        return;
    }
    else
    {
        int ans[n]={};
        while (s.size())
        {
            int r=(*begin(s)).first,i=(*begin(s)).second;
            s.erase(*begin(s));
            ans[i]=i;
            vector<pair<int,int>>z;
            for (auto [r1,j]:s)
            {
                int dis=man(a[i],a[j]);
                if (dis<=((r+r1)*(r+r1)))
                    z.push_back({r1,j});
                if (z.size()&&n>5000)
                    break;
            }
            for (auto j:z)
            {
                ans[j.second]=i;
                s.erase(j);
            }
        }
        for (auto i:ans)
            cout<<i+1<<' ';
        cout<<endl;
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 456 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 528 KB Output is correct
19 Correct 3 ms 1116 KB Output is correct
20 Correct 3 ms 1112 KB Output is correct
21 Correct 3 ms 1112 KB Output is correct
22 Correct 107 ms 1004 KB Output is correct
23 Correct 116 ms 984 KB Output is correct
24 Correct 120 ms 996 KB Output is correct
25 Correct 101 ms 860 KB Output is correct
26 Correct 110 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 355 ms 38960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Execution timed out 3080 ms 11600 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3022 ms 33208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 456 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 528 KB Output is correct
19 Correct 3 ms 1116 KB Output is correct
20 Correct 3 ms 1112 KB Output is correct
21 Correct 3 ms 1112 KB Output is correct
22 Correct 107 ms 1004 KB Output is correct
23 Correct 116 ms 984 KB Output is correct
24 Correct 120 ms 996 KB Output is correct
25 Correct 101 ms 860 KB Output is correct
26 Correct 110 ms 1004 KB Output is correct
27 Incorrect 6 ms 1628 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 456 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 528 KB Output is correct
19 Correct 3 ms 1116 KB Output is correct
20 Correct 3 ms 1112 KB Output is correct
21 Correct 3 ms 1112 KB Output is correct
22 Correct 107 ms 1004 KB Output is correct
23 Correct 116 ms 984 KB Output is correct
24 Correct 120 ms 996 KB Output is correct
25 Correct 101 ms 860 KB Output is correct
26 Correct 110 ms 1004 KB Output is correct
27 Incorrect 355 ms 38960 KB Output isn't correct
28 Halted 0 ms 0 KB -