# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1086567 | 2024-09-11T04:34:37 Z | daoquanglinh2007 | Passport (JOI23_passport) | C++17 | 0 ms | 344 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair <int, int> #define fi first #define se second #define mp make_pair #define isz(a) (int)(a).size() const int NM = 2500, inf = 1e9+7; int ntest = 1; int N, L[NM+5], R[NM+5], Q, dp[NM+5][NM+5]; void solve(){ cin >> N; for (int i = 1; i <= N; i++) cin >> L[i] >> R[i]; cin >> Q; while (Q--){ int X; cin >> X; for (int i = 1; i <= N; i++) for (int j = i; j <= N; j++) dp[i][j] = +inf; dp[X][X] = 0; int t = 0; for (int i = N; i >= 1; i--) for (int j = i; j <= N; j++){ if (dp[i][j] == +inf) continue; for (int k = i; k <= j; k++) if (L[k] < i || R[k] > j) dp[min(i, L[k])][max(j, R[k])] = min(dp[min(i, L[k])][max(j, R[k])], dp[i][j]+1); t++; } exit(t); cout << (dp[1][N] == +inf ? -1 : dp[1][N]) << '\n'; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //cin >> ntest; while (ntest--){ solve(); } #ifdef daoquanglinh2007 cout << '\n'; for (int i = 1; i <= 100; i++) cout << '='; cout << "\nExecution time: " << 1*(clock()) << " ms\n"; #endif return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 344 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 344 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 344 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 344 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 344 KB | Execution failed because the return code was nonzero |
2 | Halted | 0 ms | 0 KB | - |