# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92537 | Shtef | NLO (COCI18_nlo) | C++14 | 409 ms | 66560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |