Submission #1297088

#TimeUsernameProblemLanguageResultExecution timeMemory
1297088chaitanyamehtaLightning Rod (NOI18_lightningrod)C++20
7 / 100
1106 ms156136 KiB
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int n; cin>>n; vector<pair<int , int>> a(n ); for(int i = 0 ; i < n ;i++)cin>>a[i].first >> a[i].second; int total = (1 << n); int best = LLONG_MAX; for(int i = 0 ; i < total ; i++){ vector<int> placed(n , 0); int ans = 0; for(int k = 0 ; k < n; k++){ if((1 << k) & i){ placed[k]=1; ans++; // cout << k << " " << i << " " << ans <<"\n"; } } for(int w = 0 ; w < n ; w++){ if(placed[w]){ for(int j = w -1; j >= 0; j--){ if(abs(a[w].first - a[j].first) <= abs(a[w].second - a[j].second)) placed[j]=1; } for(int j = w +1; j <n; j++){ if(abs(a[w].first - a[j].first) <= abs(a[w].second - a[j].second)) placed[j]=1; } } } bool ok = true; for(int j = 0 ; j< n ; j++){ if(!placed[j]) ok = false; } if(ok && ans != 0) best = min(best , ans); // if(best == 1){ // cout<< i << "\n"; // } } cout<<best; }
#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...