Submission #831943

#TimeUsernameProblemLanguageResultExecution timeMemory
831943DarkMatterLightning Rod (NOI18_lightningrod)C++14
23 / 100
2062 ms262144 KiB
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #include<unordered_map> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int>pi; typedef pair<ll, ll>pl; typedef vector<pi>vpi; typedef vector<pl>vpl; typedef vector<vi> vvi; typedef vector<vl> vvl; typedef vector<string> vs; typedef vector<bool> vb; const long double PI = acos(-1); const ll oo = 1e18; const int MOD = 1e9 + 7; const int N = 2e5 + 7; #define endl '\n' #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define read(v) for (auto& it : v) scanf("%d", &it); #define readL(v) for (auto& it : v) scanf("%lld", &it); #define print(v) for (auto it : v) printf("%d ", it); puts(""); #define printL(v) for (auto it : v) printf("%lld ", it); puts(""); ll n; vpl v; ll ans = oo; void calc(ll idx, vpl cur) { if (idx == n) { vb vis(n, false); for (int i = 0; i < cur.size(); i++) { for (int j = 0; j < n; j++) { if (vis[j]) continue; if (abs(cur[i].first - v[j].first) <= (cur[i].second - v[j].second)) vis[j] = true; } } sort(all(vis)); if (vis[0]) ans = min(ans, (ll)cur.size()); return; } calc(idx + 1, cur); cur.push_back(v[idx]); calc(idx + 1, cur); } void solve() { scanf("%lld", &n); v.resize(n); ans = oo; bool ok = true; for (auto& it : v) { scanf("%lld %lld", &it.first, &it.second); if (it.second != 1) ok = false; } if (ok) { cout << n << endl; return; } vpl cur; calc(0, cur); printf("%lld\n", ans); } int t = 1; int main() { //#ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); //#endif //scanf("%d", &t); while (t--) solve(); }

Compilation message (stderr)

lightningrod.cpp: In function 'void calc(ll, vpl)':
lightningrod.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for (int i = 0; i < cur.size(); i++) {
      |                   ~~^~~~~~~~~~~~
lightningrod.cpp: In function 'void solve()':
lightningrod.cpp:52:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
lightningrod.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |   scanf("%lld %lld", &it.first, &it.second);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...