# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92561 | Shtef | NLO (COCI18_nlo) | C++14 | 616 ms | 504 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 <ll, ll> pll;
#define x first
#define y second
#define mp make_pair
struct query{
ll x, y, r;
};
ll n, m, k;
query a[105];
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){
cin >> a[i].x >> a[i].y >> a[i].r;
}
ll sol = 0;
for(int i = 1 ; i <= m ; ++i){
ll last = 1;
vector <pll> v;
for(int j = 0 ; j < k ; ++j){
ll x = a[j].x, y = a[j].y, r = a[j].r, val = j + 1;
if(i >= max(1LL, y - r) && i <= min(m, y + r)){
ll koef = (r - i + y) * (r + i - y);
ld t = sqrt(koef);
koef = (ll)t;
v.push_back(mp(max(1LL, x - koef), val));
v.push_back(mp(min(n + 1, x + koef + 1), -val));
}
}
set <ll, greater <ll> > s;
sort(v.begin(), v.end());
for(int j = 0 ; j < v.size() ; ){
ll t = v[j].x;
sol += (t - last) * (k - (!s.empty() ? *s.begin() : 0LL));
while(j < v.size() && v[j].x == t){
ll o = v[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... |