# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
513807 | wildturtle | NLO (COCI18_nlo) | C++14 | 581 ms | 440 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 ll long long
#define f first
#define sc second
#define pb push_back
using namespace std;
int a,b,c,d,i,e,f,g,n,m,k,l,minn,t,le,ri,maxx,sz,cur,curr;
ll ans;
pair < pair <int,int> , int> A[500005];
int tree[500005],tree1[500005];
vector < pair <int,int> > v;
multiset <int> ms;
int main() {
std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>m;
cin>>k;
for(int i=1;i<=k;i++) {
cin>>A[i].f.f>>A[i].f.sc>>A[i].sc;
}
ans=n*m*k;
for(int i=1;i<=n;i++) {
v.clear(); ms.clear();
for(int j=k;j>=1;j--) {
if(abs(i-A[j].f.f)>A[j].sc) continue;
sz=(A[j].sc*A[j].sc)-(abs(i-A[j].f.f)*abs(i-A[j].f.f));
sz=sqrtl(sz);
le=A[j].f.sc-sz;
ri=A[j].f.sc+sz;
v.pb({le,j});
v.pb({ri+1,-j});
}
v.pb({m+1,0});
sort(v.begin(),v.end());
for(ll j=0;j<v.size()-1;j++) {
if(v[j].sc>=0) ms.insert(v[j].sc);
else ms.erase(ms.find(-v[j].sc));
if(ms.size()) {
a=*(--ms.end());
ans-=a*(v[j+1].f-v[j].f);
}
}
}
cout<<ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |