Submission #513808

# Submission time Handle Problem Language Result Execution time Memory
513808 2022-01-17T16:17:04 Z wildturtle NLO (COCI18_nlo) C++14
110 / 110
556 ms 340 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define sc second
#define pb push_back
using namespace std;
ll a,b,c,d,i,e,f,g,n,m,k,l,minn,t,le,ri,maxx,sz,cur,curr;
ll ans;
pair < pair <ll,ll> , ll> A[500005];
ll tree[500005],tree1[500005];
vector < pair <ll,ll> > v;
multiset <ll> ms;
int main() {
    std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n>>m;
    cin>>k;
    for(ll i=1;i<=k;i++) {
        cin>>A[i].f.f>>A[i].f.sc>>A[i].sc;
    }
    ans=n*m*k;
    for(ll i=1;i<=n;i++) {
        v.clear(); ms.clear();
        for(ll 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

nlo.cpp: In function 'int main()':
nlo.cpp:34:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(ll j=0;j<v.size()-1;j++) {
      |                    ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 9 ms 340 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 41 ms 332 KB Output is correct
5 Correct 25 ms 336 KB Output is correct
6 Correct 226 ms 336 KB Output is correct
7 Correct 75 ms 204 KB Output is correct
8 Correct 428 ms 320 KB Output is correct
9 Correct 134 ms 332 KB Output is correct
10 Correct 556 ms 312 KB Output is correct