Submission #16600

# Submission time Handle Problem Language Result Execution time Memory
16600 2015-08-29T11:29:43 Z eaststar 버스 (JOI14_bus) C++14
100 / 100
321 ms 18304 KB
#include <bits/stdc++.h>
using namespace std;
struct data{
    int e,x,y;
    bool operator<(const data&r)const{
        return x<r.x;
    }
};
priority_queue<data> q[100010];
struct answer{
    int x,y;
    bool operator<(const answer&r)const{
        return y>r.y;
    }
}ans[300010];
int mn[100010],n,cnt;
int dfs(int p,int y){
    if(p==n)return y;
    while(!q[p].empty()&&q[p].top().x>=y){
        data t=q[p].top();
        q[p].pop();
        mn[p]=min(mn[p],dfs(t.e,t.y));
    }
    return mn[p];
}
int main(){
    int i,m,a,b,x,y;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;++i){
        scanf("%d%d%d%d",&a,&b,&x,&y);
        q[a].push({b,x,y});
    }
    for(i=1;i<=n;++i)mn[i]=1e8;
    while(!q[1].empty()){
        a=q[1].top().x;
        ans[cnt++]={a,dfs(1,a)};
    }
    scanf("%d",&m);
    for(;m--;){
        answer t;
        t.x=0;
        scanf("%d",&t.y);
        i=lower_bound(ans,ans+cnt,t)-ans;
        printf("%d\n",i<cnt?ans[i].x:-1);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 7580 KB Output is correct
2 Correct 0 ms 7580 KB Output is correct
3 Correct 0 ms 7580 KB Output is correct
4 Correct 0 ms 7580 KB Output is correct
5 Correct 0 ms 7580 KB Output is correct
6 Correct 0 ms 7580 KB Output is correct
7 Correct 0 ms 7580 KB Output is correct
8 Correct 0 ms 7580 KB Output is correct
9 Correct 0 ms 7580 KB Output is correct
10 Correct 0 ms 7580 KB Output is correct
11 Correct 0 ms 7580 KB Output is correct
12 Correct 0 ms 7580 KB Output is correct
13 Correct 3 ms 7612 KB Output is correct
14 Correct 2 ms 7580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7580 KB Output is correct
2 Correct 33 ms 7580 KB Output is correct
3 Correct 49 ms 7580 KB Output is correct
4 Correct 0 ms 7580 KB Output is correct
5 Correct 3 ms 7580 KB Output is correct
6 Correct 0 ms 7580 KB Output is correct
7 Correct 23 ms 7580 KB Output is correct
8 Correct 0 ms 7580 KB Output is correct
9 Correct 39 ms 7580 KB Output is correct
10 Correct 31 ms 7580 KB Output is correct
11 Correct 22 ms 7616 KB Output is correct
12 Correct 0 ms 7580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 256 ms 13520 KB Output is correct
2 Correct 219 ms 13520 KB Output is correct
3 Correct 249 ms 13520 KB Output is correct
4 Correct 193 ms 13520 KB Output is correct
5 Correct 248 ms 13520 KB Output is correct
6 Correct 194 ms 13520 KB Output is correct
7 Correct 172 ms 13388 KB Output is correct
8 Correct 291 ms 13324 KB Output is correct
9 Correct 241 ms 13560 KB Output is correct
10 Correct 188 ms 14064 KB Output is correct
11 Correct 251 ms 14056 KB Output is correct
12 Correct 190 ms 14056 KB Output is correct
13 Correct 191 ms 14056 KB Output is correct
14 Correct 201 ms 14056 KB Output is correct
15 Correct 220 ms 14064 KB Output is correct
16 Correct 81 ms 18304 KB Output is correct
17 Correct 51 ms 18304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 273 ms 13520 KB Output is correct
2 Correct 249 ms 13520 KB Output is correct
3 Correct 164 ms 13520 KB Output is correct
4 Correct 196 ms 13520 KB Output is correct
5 Correct 253 ms 13520 KB Output is correct
6 Correct 264 ms 13520 KB Output is correct
7 Correct 243 ms 13388 KB Output is correct
8 Correct 245 ms 13520 KB Output is correct
9 Correct 231 ms 13560 KB Output is correct
10 Correct 218 ms 14064 KB Output is correct
11 Correct 214 ms 14056 KB Output is correct
12 Correct 321 ms 14188 KB Output is correct
13 Correct 240 ms 14064 KB Output is correct
14 Correct 230 ms 14056 KB Output is correct
15 Correct 211 ms 14064 KB Output is correct
16 Correct 68 ms 18304 KB Output is correct