답안 #741173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741173 2023-05-13T17:42:45 Z speedyArda 원 고르기 (APIO18_circle_selection) C++14
7 / 100
3000 ms 22328 KB
#include "bits/stdc++.h"
#pragma Ofast
#pragma avx2
using namespace std;
const int MAXN = 3e5+5;
vector< pair < pair<int, int>, pair<int, int> > > circles;
vector<int> ans(MAXN, 0);
bool cmp(pair < pair<int, int>, pair<int, int> > a, pair < pair<int, int>, pair<int, int> > b)
{
    if(a.second.first != b.second.first)
        return a.second.first > b.second.first;
    return a.second.second < b.second.second;
}
int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x, y, r;
        cin >> x >> y >> r;
        circles.push_back({{x, y}, {r, i}});
    }

    sort(circles.begin(), circles.end(), cmp);
    if(n <= 5e3)
    {
        for(int i = 0; i < n; i++)
        {
            if(ans[circles[i].second.second] != 0)
                continue;
            //cout << circles[i].second.second << "\n";
            ans[circles[i].second.second] = circles[i].second.second + 1;
            for(int a = 0; a < n; a++)
            {
                if(ans[circles[a].second.second] == 0)
                {
                    long double dist = sqrt(pow(abs(circles[i].first.first - circles[a].first.first), 2) + pow(abs(circles[i].first.second - circles[a].first.second), 2));
                    if(dist <= circles[i].second.first + circles[a].second.first)
                        ans[circles[a].second.second] = circles[i].second.second + 1;
                }
            }
        }
    } else 
    {
        multiset< pair<int, int> > elems;
        for(int i = 0; i < n; i++)
        {
            elems.insert({circles[i].first.first, circles[i].second.second});
        }
        for(int i = 0; i < n; i++)
        {
            if(ans[circles[i].second.second] != 0)
                continue;
            auto it = elems.find({circles[i].first.first,  circles[i].second.second});
            auto prev = it;
            vector<int> toerase;
            if(it != elems.begin()) {
                it--;
                while(true)
                {
                    if(circles[i].first.first - (*it).first <= circles[i].second.first  + circles[(*it).second].second.first)
                    {
                        toerase.push_back((*it).second);
                    } else
                        break;
                    if(it == elems.begin())
                        break;
                    it--;
                }
            }
            it = prev;
            while(it != elems.end())
            {
                if(abs(circles[i].first.first - (*it).first) <= circles[i].second.first  + circles[(*it).second].second.first)
                {
                    toerase.push_back((*it).second);
                } else
                    break;
                it++;
            }

            for(int e : toerase)
            {
                ans[circles[e].second.second] = circles[i].second.second + 1;
                elems.erase({circles[e].first.first,  circles[e].second.second});
            }
        }
    }

    for(int i = 0; i < n; i++)
        cout << ans[i] << " ";
    cout << "\n";
}

Compilation message

circle_selection.cpp:2: warning: ignoring '#pragma Ofast ' [-Wunknown-pragmas]
    2 | #pragma Ofast
      | 
circle_selection.cpp:3: warning: ignoring '#pragma avx2 ' [-Wunknown-pragmas]
    3 | #pragma avx2
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 2 ms 1492 KB Output is correct
9 Correct 2 ms 1492 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1504 KB Output is correct
12 Correct 1 ms 1508 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1492 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 2 ms 1492 KB Output is correct
17 Correct 2 ms 1516 KB Output is correct
18 Correct 1 ms 1492 KB Output is correct
19 Correct 4 ms 1760 KB Output is correct
20 Correct 4 ms 1876 KB Output is correct
21 Correct 3 ms 1756 KB Output is correct
22 Correct 87 ms 1832 KB Output is correct
23 Correct 85 ms 1836 KB Output is correct
24 Correct 82 ms 1836 KB Output is correct
25 Correct 90 ms 1824 KB Output is correct
26 Correct 83 ms 1840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3030 ms 22328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Incorrect 305 ms 8272 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 380 ms 22088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 2 ms 1492 KB Output is correct
9 Correct 2 ms 1492 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1504 KB Output is correct
12 Correct 1 ms 1508 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1492 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 2 ms 1492 KB Output is correct
17 Correct 2 ms 1516 KB Output is correct
18 Correct 1 ms 1492 KB Output is correct
19 Correct 4 ms 1760 KB Output is correct
20 Correct 4 ms 1876 KB Output is correct
21 Correct 3 ms 1756 KB Output is correct
22 Correct 87 ms 1832 KB Output is correct
23 Correct 85 ms 1836 KB Output is correct
24 Correct 82 ms 1836 KB Output is correct
25 Correct 90 ms 1824 KB Output is correct
26 Correct 83 ms 1840 KB Output is correct
27 Incorrect 10 ms 2392 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 2 ms 1492 KB Output is correct
9 Correct 2 ms 1492 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1504 KB Output is correct
12 Correct 1 ms 1508 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1492 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 2 ms 1492 KB Output is correct
17 Correct 2 ms 1516 KB Output is correct
18 Correct 1 ms 1492 KB Output is correct
19 Correct 4 ms 1760 KB Output is correct
20 Correct 4 ms 1876 KB Output is correct
21 Correct 3 ms 1756 KB Output is correct
22 Correct 87 ms 1832 KB Output is correct
23 Correct 85 ms 1836 KB Output is correct
24 Correct 82 ms 1836 KB Output is correct
25 Correct 90 ms 1824 KB Output is correct
26 Correct 83 ms 1840 KB Output is correct
27 Execution timed out 3030 ms 22328 KB Time limit exceeded
28 Halted 0 ms 0 KB -