Submission #146816

#TimeUsernameProblemLanguageResultExecution timeMemory
146816gumballNLO (COCI18_nlo)C++14
110 / 110
605 ms504 KiB
#include<bits/stdc++.h> typedef long long ll; #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; ll n,m,k,i,j,X[110],Y[110],R[110],d[110],has; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>m; cin>>k; for(i=1;i<=k;i++) cin>>X[i]>>Y[i]>>R[i]; for(i=1;i<=n;i++) { vector<pair<ll,ll> > isi; isi.pb(mp(1,k+1)); isi.pb(mp(m+1,-(k+1))); priority_queue<ll> pq; for(j=1;j<=k;j++) { ll A=abs(X[j]-i); if(A>R[j])continue; ll bes=sqrt(R[j]*R[j]-A*A); ll ki=max(1LL,Y[j]-bes); ll ka=min(m,Y[j]+bes); isi.pb(mp(ki,k-j+1)); isi.pb(mp(ka+1,-(k-j+1))); } sort(isi.begin(),isi.end()); ll sz=isi.size(); for(j=0;j<sz;j++) { if(isi[j].se>0) { d[isi[j].se]++; pq.push(-isi[j].se); } else { d[-isi[j].se]--; while((!pq.empty())&&(d[-pq.top()]==0)) pq.pop(); } if((j<(sz-1))&&(isi[j].fi!=isi[j+1].fi)) has+=(isi[j+1].fi-isi[j].fi)*((-pq.top())-1); } } cout<<has<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...