Submission #513807

# Submission time Handle Problem Language Result Execution time Memory
513807 2022-01-17T16:15:29 Z wildturtle NLO (COCI18_nlo) C++14
33 / 110
581 ms 440 KB
#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

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<int, 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 10 ms 332 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Incorrect 40 ms 332 KB Output isn't correct
5 Incorrect 26 ms 332 KB Output isn't correct
6 Incorrect 234 ms 316 KB Output isn't correct
7 Incorrect 77 ms 308 KB Output isn't correct
8 Incorrect 440 ms 332 KB Output isn't correct
9 Incorrect 129 ms 332 KB Output isn't correct
10 Incorrect 581 ms 440 KB Output isn't correct