제출 #1335523

#제출 시각아이디문제언어결과실행 시간메모리
1335523nguyengiabach1201Countries (BOI06_countries)C++20
10 / 100
5 ms4164 KiB
// https://oj.uz/problem/view/BOI06_countries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define el '\n'
#define FNAME "countries"
#define ll long long
#define int long long
#define ld long double

const int MOD = 1e9 + 7;
const ll INF = 1e18 + 7;
const double EPS = 1e-9;

void setup()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    if (fopen(FNAME ".in", "r"))
    {
        freopen(FNAME ".in", "r", stdin);
        freopen(FNAME ".out", "w", stdout);
    }

    return;
}

const int N = 1e3 + 5;
int n, x[N], y[N], s[N], ans[N];
vector<int> inDeg[N], ouDeg[N];

void dfs(int u)
{
    for (int v : ouDeg[u])
    {
        if (inDeg[v].size() >= 2)
            continue;

        ans[v] = ans[u], dfs(v);
    }
}

void solve()
{
    cin >> n;

    for (int i = 1; i <= n; ++i)
        cin >> x[i] >> y[i] >> s[i];

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
        {
            if (i == j)
                continue;

            int deltaX = x[i] - x[j], deltaY = y[i] - y[j];

            if (s[i] > s[j] * (deltaX * deltaX + deltaY * deltaY))
                inDeg[j].push_back(i), ouDeg[i].push_back(j);
        }

    for (int i = 1; i <= n; ++i)
        if (inDeg[i].size() == 0 || inDeg[i].size() >= 2)
            ans[i] = i, dfs(i);

    for (int i = 1; i <= n; ++i)
        if (inDeg[i].size() == 0)
            cout << 'K' << el;
        else if (inDeg[i].size() == 2)
            cout << 'D' << el;
        else
            cout << ans[i] << el;

    return;
}

signed main()
{
    setup();

    int t = 1;
    bool multiTest = false;

    if (multiTest)
        cin >> t;

    while (t--)
        solve();

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

countries.cpp: In function 'void setup()':
countries.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen(FNAME ".in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
countries.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen(FNAME ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...