Submission #888630

# Submission time Handle Problem Language Result Execution time Memory
888630 2023-12-18T04:33:41 Z vjudge1 Passport (JOI23_passport) C++17
6 / 100
90 ms 16804 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; cin >> n;
    vector <int> L(n), R(n);
    for ( int i = 0; i < n; i++ ){
        cin >> L[i] >> R[i];
        --L[i], --R[i];
    }
    vector <int> dp(n, n + 1);
    int qq, s; cin >> qq >> s;
    assert(qq == 1);
    --s;
    set <int> st;
    for ( int i = 0; i < n; i++ ){
        st.insert(i);
    }
    queue <int> q;
    for ( int i = L[s]; i <= R[s]; i++ ){
        dp[i] = 1;
        q.push(i);
        st.erase(i);
    }
    while ( !q.empty() ){
        int u = q.front();
        q.pop();
        auto it = st.lower_bound(L[u]);
        vector <int> er;
        while ( it != st.end() && *it <= R[u] ){
            dp[*it] = dp[u] + 1;
            q.push(*it);
            er.pb(*it);
            it = next(it);
        }
        for ( auto &x: er ){
            st.erase(x);
        }
    }
    int ans = *max_element(all(dp));
    if ( ans == n + 1 ){
        ans = -1;
    }
    cout << ans;

    cout << '\n';
}
# Verdict Execution time Memory 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 73 ms 16804 KB Output is correct
5 Correct 90 ms 15620 KB Output is correct
6 Correct 78 ms 15956 KB Output is correct
7 Correct 62 ms 15188 KB Output is correct
8 Correct 48 ms 12372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Incorrect 0 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Incorrect 0 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Incorrect 0 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 73 ms 16804 KB Output is correct
5 Correct 90 ms 15620 KB Output is correct
6 Correct 78 ms 15956 KB Output is correct
7 Correct 62 ms 15188 KB Output is correct
8 Correct 48 ms 12372 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Incorrect 0 ms 344 KB Output isn't correct
16 Halted 0 ms 0 KB -