Submission #991000

# Submission time Handle Problem Language Result Execution time Memory
991000 2024-06-01T03:45:21 Z Pacybwoah Passport (JOI23_passport) C++17
16 / 100
2000 ms 1048576 KB
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> vec(n + 1);
    for(int i = 1; i <= n; i++) cin >> vec[i].first >> vec[i].second;
    vector<vector<int>> dp(n + 1, vector<int>(n + 1, 1e9));
    dp[1][n] = 0;
    for(int l = n - 1; l > 0; l--){
        for(int i = 1; i + l - 1 <= n; i++){
            int j = i + l - 1;
            for(int k = i; k <= j; k++){
                dp[i][j] = min(dp[i][j], dp[min(i, vec[k].first)][max(j, vec[k].second)] + 1);
            }
        }
    }
    int q;
    cin >> q;
    while(q--){
        int a;
        cin >> a;
        if(dp[a][a] == 1e9) cout << "-1\n";
        else cout << dp[a][a] << "\n";
    }
}
// g++ -std=gnu++20 pC.cpp -o run -Wall -Wextra -fsanitize=undefined -fsanitize=address
# 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 460 KB Output is correct
4 Runtime error 385 ms 1048576 KB Execution killed with signal 9
5 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 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 10 ms 792 KB Output is correct
12 Correct 11 ms 600 KB Output is correct
13 Correct 10 ms 832 KB Output is correct
14 Correct 8 ms 604 KB Output is correct
15 Correct 10 ms 824 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 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 10 ms 792 KB Output is correct
12 Correct 11 ms 600 KB Output is correct
13 Correct 10 ms 832 KB Output is correct
14 Correct 8 ms 604 KB Output is correct
15 Correct 10 ms 824 KB Output is correct
16 Execution timed out 2067 ms 21852 KB Time limit exceeded
17 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 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 10 ms 792 KB Output is correct
12 Correct 11 ms 600 KB Output is correct
13 Correct 10 ms 832 KB Output is correct
14 Correct 8 ms 604 KB Output is correct
15 Correct 10 ms 824 KB Output is correct
16 Execution timed out 2067 ms 21852 KB Time limit exceeded
17 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 460 KB Output is correct
4 Runtime error 385 ms 1048576 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -