제출 #743094

#제출 시각아이디문제언어결과실행 시간메모리
743094vjudge1Lightning Rod (NOI18_lightningrod)C++17
44 / 100
2081 ms167808 KiB
#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();
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...