Submission #743094

# Submission time Handle Problem Language Result Execution time Memory
743094 2023-05-17T07:53:43 Z vjudge1 Lightning Rod (NOI18_lightningrod) C++17
44 / 100
2000 ms 167808 KB
#include<bits/stdc++.h>

using namespace std;

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

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.push_back(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:31: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]
   31 |     for(int i = 0; i<vc.size(); ++i){
      |                    ~^~~~~~~~~~
lightningrod.cpp:32: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]
   32 |         for(int j = 0; j<vc.size(); ++j){
      |                        ~^~~~~~~~~~
lightningrod.cpp:39: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]
   39 |     for(int i = 0; i<vc.size(); ++i){
      |                    ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1746 ms 164732 KB Output is correct
2 Correct 1487 ms 167808 KB Output is correct
3 Correct 1570 ms 167740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 1 ms 212 KB Output is correct
6 Correct 0 ms 256 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 0 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 1 ms 212 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 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 0 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 1 ms 212 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 9 ms 356 KB Output is correct
12 Correct 6 ms 340 KB Output is correct
13 Correct 5 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 1 ms 212 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 9 ms 356 KB Output is correct
12 Correct 6 ms 340 KB Output is correct
13 Correct 5 ms 360 KB Output is correct
14 Execution timed out 2075 ms 3048 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2081 ms 164624 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1746 ms 164732 KB Output is correct
2 Correct 1487 ms 167808 KB Output is correct
3 Correct 1570 ms 167740 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 1 ms 212 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 9 ms 356 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 5 ms 360 KB Output is correct
17 Execution timed out 2075 ms 3048 KB Time limit exceeded
18 Halted 0 ms 0 KB -