Submission #997498

# Submission time Handle Problem Language Result Execution time Memory
997498 2024-06-12T12:21:45 Z Abito Passport (JOI23_passport) C++17
0 / 100
2000 ms 531848 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
#define y1 YONE
typedef unsigned long long ull;
using namespace std;
const int N=2e5+5;
int dis[N],L[N],R[N],n,q;
bool vis[N];
void dijkstra(int s){
    for (int i=1;i<=n;i++) dis[i]=INT_MAX,vis[i]=0;
    dis[s]=0;
    priority_queue<pair<int,int>> pq;
    pq.push({0,s});
    while (!pq.empty()){
        int x=pq.top().S;
        pq.pop();
        if (vis[x]) continue;
        vis[x]=1;
        for (int i=L[x];i<=R[x];i++){
            if (dis[i]<dis[x]+1) continue;
            dis[i]=dis[x]+1;
            pq.push({-dis[i],i});
        }
    }return;
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>L[i]>>R[i];
    cin>>q;
    while (q--){
        int x;cin>>x;
        dijkstra(x);
        int mx=0;
        for (int i=1;i<=n;i++) mx=max(mx,dis[i]);
        if (mx==INT_MAX) cout<<-1<<endl;
        else cout<<mx<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Execution timed out 2075 ms 531848 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Incorrect 1 ms 4444 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Incorrect 1 ms 4444 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Incorrect 1 ms 4444 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Execution timed out 2075 ms 531848 KB Time limit exceeded
5 Halted 0 ms 0 KB -