Submission #743086

#TimeUsernameProblemLanguageResultExecution timeMemory
743086vjudge1Lightning Rod (NOI18_lightningrod)C++17
40 / 100
2082 ms5504 KiB
#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 (stderr)

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 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...