Submission #826960

# Submission time Handle Problem Language Result Execution time Memory
826960 2023-08-16T07:32:09 Z t6twotwo Passport (JOI23_passport) C++17
16 / 100
25 ms 1996 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios::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]--;
    }
    int Q, X;
    cin >> Q >> X;
    X--;
    if (N <= 300) {
        vector<int> dp(N);
        iota(dp.begin(), dp.end(), 0);
        dp[X] = X + 1;
        for (int ans = 1; ; ans++) {
            auto pd = dp;
            iota(dp.begin(), dp.end(), 0);
            for (int i = 0; i < N; i++) {
                for (int j = i; j < pd[i]; j++) {
                    dp[min(i, L[j])] = max({dp[min(i, L[j])], pd[i], R[j]});
                }
            }
            if (dp[0] == N) {
                cout << ans << "\n";
                return 0;
            }
            if (dp == pd) {
                break;
            }
        }
        cout << -1 << "\n";
        return 0;
    }
    int ans = 0;
    for (int f = R[0]; X < N - 1;) {
        if (X == f) {
            ans = -1;
            break;
        }
        ans++;
        for (int i = f - X; i; i--) {
            f = max(f, R[++X]);
        }
    }
    cout << ans << "\n";
    return 6/22;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 25 ms 1876 KB Output is correct
5 Incorrect 25 ms 1996 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 324 KB Output is correct
15 Correct 13 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 324 KB Output is correct
15 Correct 13 ms 212 KB Output is correct
16 Runtime error 1 ms 468 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 324 KB Output is correct
15 Correct 13 ms 212 KB Output is correct
16 Runtime error 1 ms 468 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 25 ms 1876 KB Output is correct
5 Incorrect 25 ms 1996 KB Output isn't correct
6 Halted 0 ms 0 KB -