# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
328421 | egas | Lightning Rod (NOI18_lightningrod) | C++14 | 2071 ms | 158672 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;
bool done[30];
int tt=0;
int solve(vector<pair<int,int> > &v) {
int res=INT_MAX;
for(int i=0; i<v.size(); i++) {
int cnt=0;
vector<int> temp;
for(int j=i; j<v.size(); j++) {
if(!done[j] and abs(v[i].second-v[j].second)>=abs(v[i].first-v[j].first)) {
done[j]=1;
cnt++;
temp.push_back(j);
}
}
for(int j=i; j>=0; j--) {
if(!done[j] and abs(v[i].second-v[j].second)>=abs(v[i].first-v[j].first)) {
done[j]=1;
temp.push_back(j);
cnt++;
}
}
if(cnt>0) {
res=min(res,1+solve(v));
}
for(int x:temp) {
done[x]=0;
}
}
if(res==INT_MAX)res=0;
return res;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<pair<int,int> > v;
bool isSub1=true;
for(int i = 0 ; i < n ; i++) {
int x;
cin >> x;
int y;
cin >> y;
if(y!=1)isSub1=false;
v.push_back({x,y});
}
if(isSub1) {
cout << n << '\n';
} else {
cout << solve(v) << '\n';
}
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... |