Submission #743086

# Submission time Handle Problem Language Result Execution time Memory
743086 2023-05-17T07:48:35 Z vjudge1 Lightning Rod (NOI18_lightningrod) C++17
40 / 100
2000 ms 5504 KB
#include<bits/stdc++.h>

using namespace std;

int ck,tmp,pa[200001];
set<int> s;
vector<pair<int, int>> vc;

int fp(int n)
{
    if(pa[n]==n) return n;
    return fp(pa[n]);
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    int n; cin>>n;
    for(int i = 0; i<n; ++i){
        int x,y; cin>>x>>y;
        pa[i] = i;
        if(i>0 && tmp!=y) ck = 1;
        tmp = y;
        vc.push_back({x,y});
    }
    if(!ck){
        cout<<n;
        return 0;
    }
    for(int i = 0; i<vc.size(); ++i){
        for(int j = 0; j<vc.size(); ++j){
            if(i==j) continue;
            if(abs(vc[i].first-vc[j].first)<=vc[i].second-vc[j].second){
                pa[j] = fp(pa[i]);
            }
        }
    }
    for(int i = 0; i<vc.size(); ++i){
        s.insert(pa[i]);
    }
    cout<<s.size();
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i = 0; i<vc.size(); ++i){
      |                    ~^~~~~~~~~~
lightningrod.cpp:31:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int j = 0; j<vc.size(); ++j){
      |                        ~^~~~~~~~~~
lightningrod.cpp:38:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 0; i<vc.size(); ++i){
      |                    ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 5444 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 10 ms 372 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 10 ms 372 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Execution timed out 2082 ms 2940 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 5504 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 5444 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -