Submission #893404

# Submission time Handle Problem Language Result Execution time Memory
893404 2023-12-27T04:30:12 Z vjudge1 Meetings 2 (JOI21_meetings2) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
#define int long long

using i64 = long long;

template <class F, class _S>
bool chmin(F &u, const _S &v){
    bool flag = false;
    if ( u > v ){
        u = v; flag |= true;
    }
    return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
    bool flag = false;
    if ( u < v ){
        u = v; flag |= true;
    }
    return flag;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k; cin >> n >> k;
    vector <int> L(n), R(n);
    for ( int i = 0; i < n; i++ ){
        cin >> L[i] >> R[i];
    }
    { // compression
        vector <int> p_;
        for ( int i = 0; i < n; i++ ){
            p_.pb(L[i]);
            p_.pb(R[i]);
        }
        sort(all(p_));
        p_.resize(unique(all(p_)) - p_.begin());
        auto get = [&](int x){
            return lower_bound(all(p_), x) - p_.begin() + 1;
        };
        for ( int i = 0; i < n; i++ ){
            L[i] = get(L[i]);
            R[i] = get(R[i]);
        }
    }
    int m = n * 2;
    vector <vector<int>> qu(m + 1);
    for ( int i = 0; i < n; i++ ){
        qu[L[i]].pb(R[i]);
    }
    vector <int> dp(m + 2);
    for ( int i = m; i > 0; i-- ){
        dp[i] = dp[i + 1];
        for ( auto &j: qu[i] ){
            chmax(dp[i], dp[j] + 1);
        }
    }
    if ( dp[1] < k ){
        return cout << "-1\n", 0;
    }
    vector <int> ans;
    int lst = -1;
    for ( int t = 1; t <= k; t++ ){
        int j = -1;
        for ( int i = 0; i < n; i++ ){
            if ( lst > L[i] ){
                continue;
            }
            if ( dp[R[i]] >= k - t ){
                j = i; break;
            }
        }
        if ( j == -1 ){
            return cout << "-1\n", 0;
        }
        ans.pb(j);
        lst = R[j];
    }
    sort(all(ans));
    for ( auto &x: ans ){
        cout << x + 1 << ln;
    }

    cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -