# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830609 | vjudge1 | Lightning Rod (NOI18_lightningrod) | C++17 | 2065 ms | 189480 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>
#define ll long long
#define fi first
#define se second
using namespace std;
const int nmax = 1e7+7;
struct point {
int x;
int y;
int dex;
};
bool cmp(point &a, point&b) {
return (a.y > b.y);
}
int par[nmax];
bool soada[nmax] = {false};
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int N;
cin >> N;
vector<point>tik(N+1);
for(int i=1; i<=N; i++) par[i]=i;
for(int i=0; i<N; i++) {
cin >> tik[i].x >> tik[i].y;
}
sort(tik.begin(), tik.end(), cmp);
for(int i=0; i<N; i++) {
tik[i].dex = i+1;
}
vector<int>dafter;
while(!tik.empty()) {
dafter.push_back(0);
for(int i=1; i<tik.size(); i++) {
if(abs(tik[0].x - tik[i].x) <= tik[0].y-tik[i].y) {
par[tik[i].dex] = tik[0].dex;
//cout << "par[" << tik[i].dex << "] = " << tik[0].dex << endl;
dafter.push_back(i);
}
}
int kur = 0;
for(int j=0; j<dafter.size(); j++) {
//cout << "dafter " << dafter[j] << endl;
tik.erase(tik.begin()+dafter[j]-kur);
kur++;
}
dafter.clear();
}
int cost = 0;
for(int i=1; i<=N; i++) {
if(soada[par[i]]==false) {
cost++;
soada[par[i]]=true;
}
}
cout << cost << endl;
return 0;
}
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... |