# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743094 | vjudge1 | Lightning Rod (NOI18_lightningrod) | C++17 | 2081 ms | 167808 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |