# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92206 | Shtef | NLO (COCI18_nlo) | C++14 | 3057 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;
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |