제출 #1341802

#제출 시각아이디문제언어결과실행 시간메모리
1341802BlockOGCountries (BOI06_countries)C++20
100 / 100
3 ms344 KiB
#include <bits/stdc++.h>

// mrrrowwww meeowwwww :3
// go play vivid/stasis! !! !!! https://vividstasis.gay

#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;

int ____init = []{
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    return 0;
}();

pair<pair<int, int>, int> cities[1000];
bool overpowered[1000];
int par[1000];

int get(int i) {
    if (par[i] == i) return i;
    return par[i] = get(par[i]);
}

void merge(int i, int j) {
    i = get(i), j = get(j);
    if (i == j) return;
    par[j] = i;
}

int dist(pair<int, int> a, pair<int, int> b) {
    return (a.f - b.f) * (a.f - b.f) + (a.s - b.s) * (a.s - b.s);
}

int main() {
    int n; cin >> n;
    fo(i, 0, n) par[i] = i, cin >> cities[i].f.f >> cities[i].f.s >> cities[i].s;

    fo(i, 0, n) {
        int k = (i + 1) % n;
        bool mult = false;
        fo(j, 0, n) {
            if (i == j || k == j) continue;

            if (cities[j].s * dist(cities[i].f, cities[k].f) > cities[k].s * dist(cities[i].f, cities[j].f)) {
                k = j;
                mult = false;
            } else if (cities[j].s * dist(cities[i].f, cities[k].f) == cities[k].s * dist(cities[i].f, cities[j].f))
                mult = true;
        }

        if (cities[k].s > cities[i].s * dist(cities[i].f, cities[k].f)) {
            overpowered[i] = true;
            if (!mult)
                merge(k, i);
        }
    }

    fo(i, 0, n) {
        if (get(i) == i)
            cout << (overpowered[i] ? "D" : "K") << endl;
        else
            cout << get(i) + 1 << endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...