# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
313339 | neki | NLO (COCI18_nlo) | C++14 | 516 ms | 508 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 <bits/stdc++.h>
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 260000
#define pa pair<ll, ll>
#define ld long double
ll x[mn], y[mn], r[mn];
int main(){
ll n, m, ans=0;cin >> n>>m;
ll k;cin >> k;
loop(i, 2, k+2) cin >> x[i]>>y[i]>>r[i];
loop(i, 1, n+1){
vc<pa> ne;
loop(j, 2, k+2){
ll temp=r[j] * r[j] - (i-x[j]) * (i-x[j]);
if(temp>=0){
temp=sqrt(temp);
ne.ps(make_pair(max((ll) 1, y[j]-temp), -j));
ne.ps(make_pair(min(m+1, y[j]+temp+1), j));
}
}
ll act[110];
loop(j, 0, 110)act[j]=0;
ne.ps(make_pair(1, -1));
ne.ps(make_pair(m+1, 1));
sort(all(ne));
priority_queue<ll> q;
loop(v, 0, (ll)((ll)ne.size()-1)){
if(ne[v].se>0) act[ne[v].se]=0;
else{
act[-ne[v].se]=1;
q.push(-ne[v].se);
}
while(q.size() and !act[q.top()])q.pop();
if(!q.size()) cout << i << endl;
ans+=(k+1-q.top()) * (ne[v+1].fi - ne[v].fi);
}
}
cout << ans <<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |