답안 #173481

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173481 2020-01-04T08:55:34 Z Tuk1352 Countries (BOI06_countries) C++11
95 / 100
11 ms 376 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, I;
    cin >> n;
    long double X[n], Y[n], s[n], d, M;
    int C[n], Im, k;
    vector <pair<int,int>> V;
    for (int i = 0; i < n; i++)
    {
        cin >> X[i] >> Y[i] >> s[i];
        V.push_back({s[i],i});
    }
    sort(V.rbegin(),V.rend());
    for (int i = 0; i < V.size(); i++)
    {
        I = V[i].second;
        Im = I;
        M = 0;
        k = 0;
        for (int y = 0; y < n; y++)
        {
            if (I != y)
            {
                d = s[y]/((X[I]-X[y])*(X[I]-X[y])+(Y[I]-Y[y])*(Y[I]-Y[y]));
                if (d > s[I])
                {
                    if (d > M)
                    {
                        M = d;
                        k = 1;
                        Im = y;
                    }
                    else if (d == M)
                    {
                        k++;
                    }
                }
            }
        }
        if (k == 0)
        {
            C[I] = I;
        }
        else if (k == 2)
        {
            C[I] = -1;
        }
        else
        {
            C[I] = C[Im];
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (C[i] == i)
        {
            cout << "K" << "\n";
        }
        else if (C[i] == -1)
        {
            cout << "D" << "\n";
        }
        else
        {
            cout << C[i]+1 << "\n";
        }
    }
    return 0;
}

Compilation message

countries.cpp: In function 'int main()':
countries.cpp:18:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < V.size(); i++)
                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 3 ms 376 KB Output isn't correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 8 ms 360 KB Output is correct
9 Correct 9 ms 376 KB Output is correct
10 Correct 11 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 7 ms 376 KB Output is correct
18 Correct 8 ms 376 KB Output is correct
19 Correct 11 ms 376 KB Output is correct
20 Correct 11 ms 376 KB Output is correct