# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
702419 | chenyan | NLO (COCI18_nlo) | C++17 | 998 ms | 2024 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>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define N 200010
int ans,x[N],y[N],r[N],sq[N];
struct A{
int l,r,w;
};
vector<A>v;
vector<int>u;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,m,i,j,k;
cin>>n>>m>>k;
for(i=0;i<N;i++)sq[i]=i*i;
for(i=1;i<=k;i++) cin>>x[i]>>y[i]>>r[i];
for(j=1;j<=n;j++){
for(i=1;i<=k;i++){
int xx=r[i]*r[i]-(j-x[i])*(j-x[i]);
if(xx<0)continue;
int p=upper_bound(sq,sq+N,xx)-sq-1;
v.pb({y[i]-p,y[i]+p+1,i});
u.pb(v.back().l);
u.pb(v.back().r);
}
sort(all(u)),u.resize(unique(all(u))-u.begin());
for(auto&[l,r,w]:v){
l=lower_bound(all(u),l)-u.begin();
r=lower_bound(all(u),r)-u.begin();
}
sort(all(v),[](A u,A v){return u.l<v.l;});
priority_queue<pii>pq;
pq.push({0,1e9});
int l=1,x;
for(i=0,x=0;i<u.size();i++){
ans+=(u[i]-l)*pq.top().ff;
l=u[i];
while(x<k&&v[x].l==i)pq.push({v[x].w,v[x].r}),x++;
while(pq.top().ss<=i)pq.pop();
}
vector<int>().swap(u);
vector<A>().swap(v);
}
cout<<n*m*k-ans<<'\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |