# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
978540 | 2024-05-09T10:15:49 Z | vjudge1 | Passport (JOI23_passport) | C++17 | 2000 ms | 19640 KB |
#include<bits/stdc++.h> #define sz size() #define ll long long using namespace std; const ll N = 500500; const ll INF = 1e18; void solve() { ll n, Q, i, j, k; cin >> n; ll l[n + 1], r[n + 1]; for(i = 1; i <= n; ++i) cin >> l[i] >> r[i]; cin >> Q; while(Q--) { ll start; cin >> start; ll cl = start, cr = start; vector<ll> d(n + 1, INF); d[start] = 0; multiset<pair<ll, ll>> q; q.insert({0, start}); while(q.sz) { ll s = (*q.begin()).second; q.erase(q.find(*q.begin())); for(ll t = l[s]; t <= min(cl, s); ++t) { if(d[t] <= d[s] + 1) continue; q.erase({d[t], t}); d[t] = d[s] + 1; q.insert({d[t], t}); } for(ll t = max(s, cr); t <= r[s]; ++t) { if(d[t] <= d[s] + 1) continue; q.erase({d[t], t}); d[t] = d[s] + 1; q.insert({d[t], t}); } } ll ans = max(d[1], d[n]); cout << (ans < INF ? ans : -1) << '\n'; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 504 KB | Output is correct |
4 | Execution timed out | 2071 ms | 19640 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 456 KB | Output is correct |
7 | Incorrect | 0 ms | 348 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 456 KB | Output is correct |
7 | Incorrect | 0 ms | 348 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 456 KB | Output is correct |
7 | Incorrect | 0 ms | 348 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 504 KB | Output is correct |
4 | Execution timed out | 2071 ms | 19640 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |