Submission #531149

#TimeUsernameProblemLanguageResultExecution timeMemory
531149OttoTheDinoCountries (BOI06_countries)C++17
100 / 100
5 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i,s,e) for (int i = s; i <= e; ++i) #define rrep(i,s,e) for (int i = s; i >= e; --i) #define pb push_back #define pf push_front #define fi first #define se second #define all(a) a.begin(), a.end() typedef long long ll; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<double> vd; typedef vector<string> vs; typedef vector<ll> vll; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int x[n+1], y[n+1], s[n+1], cap[n+1] = {}; rep (i,1,n) cin >> x[i] >> y[i] >> s[i]; rep (i,1,n) { int rul = i, de = 0; rep (j,1,n) { if (i==j) continue; if (rul==i) { int d2 = (x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]); if ((s[j]+d2-1)/d2>s[i]) rul = j; } else { int dr2 = (x[rul]-x[i])*(x[rul]-x[i])+(y[rul]-y[i])*(y[rul]-y[i]); int d2 = (x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]); if (s[j]*dr2>s[rul]*d2) { rul = j; de = 0; } else if (s[j]*dr2==s[rul]*d2) { de = 1; } } } if (de) continue; cap[i] = rul; } rep (i,1,n) { int c = cap[i]; while (c != cap[c]) c = cap[c]; if (c==i) cout << "K\n"; else if (!c) cout << "D\n"; else cout << c << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...