# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92544 | Shtef | NLO (COCI18_nlo) | C++14 | 377 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>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define x first
#define y second
#define mp make_pair
int n, m, k;
vector <pii> c[100005];
void processcircle(int x, int y, int r, int val){
for(int i = max(1, y - r) ; i <= min(m, y + r) ; ++i){
int koef = sqrt((ll)(r - i + y) * (r + i - y));
c[i].push_back(mp(max(1, x - koef), val));
c[i].push_back(mp(min(n + 1, x + koef + 1), -val));
}
}
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){
int x, y, r;
cin >> x >> y >> r;
processcircle(x, y, r, i + 1);
}
ll sol = 0;
for(int i = 1 ; i <= m ; ++i){
int last = 1;
set <int, greater <int> > s;
sort(c[i].begin(), c[i].end());
for(int j = 0 ; j < c[i].size() ; ){
int t = c[i][j].x;
sol += (ll)(t - last) * (k - (!s.empty() ? *s.begin() : 0LL));
while(j < c[i].size() && c[i][j].x == t){
int o = c[i][j].y;
if(o < 0){
s.erase(s.find(-o));
}
else{
s.insert(o);
}
j++;
}
last = t;
}
sol += (n + 1 - last) * k;
}
cout << sol << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |