Submission #92206

#TimeUsernameProblemLanguageResultExecution timeMemory
92206ShtefNLO (COCI18_nlo)C++14
11 / 110
3057 ms66560 KiB
#include <iostream> #include <map> #include <vector> #include <cmath> #include <set> using namespace std; typedef long long ll; 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 = (ll)r * (ll)r - (ll)(i - y) * (ll)(i - y); ll t = (ll)sqrt(koef); c[i][max(1LL, x - t)].push_back(val); c[i][min(n + 1, x + t + 1)].push_back(-val); //cout << i << ' ' << t << endl; } //cout << endl; //system("pause"); } 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(y, x, r, i + 1); } for(int i = 1 ; i <= m ; ++i){ c[i][n + 1].push_back(0); } ll sol = 0; //cout << endl; for(int i = 1 ; i <= m ; ++i){ set <ll, greater <ll> > s; ll last = 1; for(map <ll, vector <ll> >::iterator j = c[i].begin() ; j != c[i].end() ; ++j){ //cout << last << ' ' << j->first << ' ' << (!s.empty() ? *s.begin() : 0) << endl; sol += (j->first - last) * (k - (!s.empty() ? *s.begin() : 0)); vector <ll> v = j->second; for(vector <ll>::iterator w = v.begin() ; w != v.end() ; ++w){ ll o = *w; if(o < 0){ s.erase(s.find(-o)); } else{ s.insert(o); } } last = j->first; } //cout << endl; } cout << sol << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...