답안 #1027548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027548 2024-07-19T07:27:40 Z Issa Fire (BOI24_fire) C++17
0 / 100
1 ms 348 KB
#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

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){
      |                 ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -