Submission #92537

#TimeUsernameProblemLanguageResultExecution timeMemory
92537ShtefNLO (COCI18_nlo)C++14
44 / 110
409 ms66560 KiB
#include <iostream> #include <map> #include <vector> #include <cmath> #include <set> using namespace std; typedef long long ll; typedef long double ld; ll n, m, k; map <ll, vector <ll> > c[100005]; void processcircle(ll x, ll y, ll r, ll val){ for(int i = max(1LL, y - r) ; i <= min(m, y + r) ; ++i){ ll koef = (r - i + y) * (r + i - y); ld t = sqrt(koef); koef = (ll)t; c[i][max(1LL, x - koef)].push_back(val); c[i][min(n + 1, x + koef + 1)].push_back(-val); } } bool cmp(ll x, ll y){ return x > y; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; cin >> k; for(int i = 0 ; i < k ; ++i){ ll x, y, r; cin >> x >> y >> r; processcircle(x, y, r, i + 1); } ll sol = 0; for(int i = 1 ; i <= m ; ++i){ ll last = 1; set <ll, greater <ll> > s; for(map <ll, vector <ll> >::iterator j = c[i].begin() ; j != c[i].end() ; ++j){ ll t = j->first; sol += (t - last) * (k - (!s.empty() ? *s.begin() : 0LL)); vector <ll> o = j->second; for(vector <ll>::iterator v = o.begin() ; v != o.end() ; ++v){ ll u = *v; if(u < 0){ s.erase(s.find(-u)); } else{ s.insert(u); } } last = t; } sol += (n + 1 - last) * k; } cout << sol << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...