Submission #921697

# Submission time Handle Problem Language Result Execution time Memory
921697 2024-02-04T09:10:40 Z vjudge1 Lightning Rod (NOI18_lightningrod) C++17
44 / 100
251 ms 616 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

void solve(){
    ll a,ans=0;
    cin>>a;
    if(a>2000){
        cout<<a;
        return ;
    }
    map<pair<ll,ll>,ll>mp;
    vector<pair<ll,ll> > v;
    for(ll i=1;i<=a;i++){
        ll x,y;
        cin>>x>>y;
        v.pb({y,x});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    if(v[0].second==v[v.size()-1].second){
        cout<<a;
        return ;
    }
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j<v.size();j++){
            if(mp[v[j]]==0 && j!=i && mp[v[i]]==0){
                if(abs(v[i].second-v[j].second)<=v[i].first-v[j].first){
                    mp[v[j]]=1;
                    //cout<<v[j].first<<" "<<v[j].second<<"\n";
                }
            }
        }
    }    
    for(ll i=0;i<v.size();i++){
        if(mp[v[i]]==0){
            ans++;
        }
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    ll t=1,i=1;
    //cin>>t;
    while(t--){
        //cout<<"Case ";
        //cout<<i<<':'<<"\n";
        //i++;
        solve();
    }
    return 0;
}

Compilation message

lightningrod.cpp: In function 'void solve()':
lightningrod.cpp:26:17: 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]
   26 |     for(ll i=0;i<v.size();i++){
      |                ~^~~~~~~~~
lightningrod.cpp:27: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]
   27 |         for(ll j=0;j<v.size();j++){
      |                    ~^~~~~~~~~
lightningrod.cpp:36:17: 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]
   36 |     for(ll i=0;i<v.size();i++){
      |                ~^~~~~~~~~
lightningrod.cpp: In function 'int main()':
lightningrod.cpp:47:12: warning: unused variable 'i' [-Wunused-variable]
   47 |     ll t=1,i=1;
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 180 ms 600 KB Output is correct
12 Correct 214 ms 604 KB Output is correct
13 Correct 251 ms 616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 180 ms 600 KB Output is correct
12 Correct 214 ms 604 KB Output is correct
13 Correct 251 ms 616 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 180 ms 600 KB Output is correct
15 Correct 214 ms 604 KB Output is correct
16 Correct 251 ms 616 KB Output is correct
17 Incorrect 0 ms 348 KB Output isn't correct
18 Halted 0 ms 0 KB -