Submission #1027548

#TimeUsernameProblemLanguageResultExecution timeMemory
1027548IssaFire (BOI24_fire)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ent "\n" const int maxn = 3e5 + 100; const ll INF = (ll)1e18 + 100; const int inf = 1e9 + 100; const int MOD = 1e9 + 7; const int maxl = 350; const int P = 31; int n, m; pii a[maxn]; void test(){ cin >> n >> m; for(int i = 0; i < n; i++){ cin >> a[i].first >> a[i].second; } vector<pii> v; int ans = inf; for(int i = 1; i < (1<<n); i++){ v.clear(); for(int j = 0; j < n; j++){ if(i & (1<<j)){ v.push_back({a[j].first, 1}); v.push_back({a[j].second, -1}); if(a[j].first > a[j].second) v.push_back({1, 1}); } } bool ok = 1; sort(v.begin(), v.end()); for(int i = 0; i < v.size(); i++){ if(i) v[i].second += v[i-1].second; if((i == v.size() - 1 || v[i+1].first > v[i].first) && !v[i].second){ ok = 0; break; } } if(ok){ ans = min(ans, __builtin_popcount(i)); } } if(ans == inf) ans = -1; cout << ans; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; t = 1; while(t--) test(); cout << ent; }

Compilation message (stderr)

Main.cpp: In function 'void test()':
Main.cpp:36:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i = 0; i < v.size(); i++){
      |                        ~~^~~~~~~~~~
Main.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             if((i == v.size() - 1 || v[i+1].first > v[i].first) && !v[i].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...