Submission #692842

#TimeUsernameProblemLanguageResultExecution timeMemory
692842saayan007Lightning Rod (NOI18_lightningrod)C++17
19 / 100
2093 ms175688 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pi = pair<int, int>; using pl = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vpi = vector<pi>; using vpl = vector<pl>; #define fur(i, a, b) for(ll i = a; i <= (ll) b; ++i) #define ruf(i, a, b) for(ll i = a; i >= (ll) b; --i) #define fr first #define sc second #define mp make_pair #define pb push_back #define eb emplace_back #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define nl "\n" int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; ll x[n + 1], y[n + 1]; fur(i, 1, n) { cin >> x[i] >> y[i]; } ll ans = n; fur(i, 0, (1 << n) - 1) { bool rod[n + 1] = {}; bool prot[n + 1] = {}; fur(j, 0, n - 1) { if(i & (1 << j)) rod[j + 1] = 1; } fur(j, 1, n) { if(!rod[j]) continue; fur(k, 1, n) { if(abs(x[k] - x[j]) <= y[j] - y[k]) prot[k] = 1; } } bool all = 1; fur(j, 1, n) all &= prot[j]; if(all) { ans = min(ans, (ll)__builtin_popcountll(i)); } } cout << ans << nl; }
#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...