# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1027548 | Issa | Fire (BOI24_fire) | C++17 | 1 ms | 348 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;
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)
# | 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... |