Submission #16538

# Submission time Handle Problem Language Result Execution time Memory
16538 2015-08-27T11:52:56 Z eaststar 버스 (JOI14_bus) C++14
0 / 100
265 ms 9680 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
struct data{
    int a,b,x,y;
    bool operator<(const data&r)const{
        if(a==r.a)return x>r.x;
        return a<r.a;
    }
}a[300010];
struct ans{
    int s,e;
    bool operator<(const ans&r)const{
        if(e==r.e)return s>r.s;
        return e>r.e;
    }
}b[300010],t;
int st[100010],chk[300010],cnt,n,m;
int f(int p,int t){
    int m=1e8;
    if(p==n)return t;
    for(int &i=st[p];a[i].a==p&&a[i].x>=t;++i)m=min(m,f(a[i].b,a[i].y));
    return m;
}
int main(){
    int i,q;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;++i)scanf("%d%d%d%d",&a[i].a,&a[i].b,&a[i].x,&a[i].y);
    sort(a+1,a+m+1);
    for(i=1;i<=m;++i)if(a[i].a!=a[i-1].a)st[a[i].a]=i;
    a[0].x=-1;
    for(i=1;a[i].a==1;++i)b[cnt].s=a[i].x,b[cnt++].e=f(1,a[i].x);
    sort(b,b+cnt);
    scanf("%d",&q);
    t.s=1e9;
    for(;q--;){
        scanf("%d",&t.e);
        i=lower_bound(b,b+cnt,t)-b;
        printf("%d\n",i==cnt?-1:b[i].s);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 9680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 9680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 183 ms 9680 KB Output is correct
2 Correct 194 ms 9680 KB Output is correct
3 Correct 235 ms 9680 KB Output is correct
4 Correct 265 ms 9680 KB Output is correct
5 Correct 180 ms 9680 KB Output is correct
6 Correct 207 ms 9680 KB Output is correct
7 Correct 254 ms 9680 KB Output is correct
8 Correct 253 ms 9680 KB Output is correct
9 Incorrect 191 ms 9680 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 192 ms 9680 KB Output is correct
2 Correct 217 ms 9680 KB Output is correct
3 Correct 159 ms 9680 KB Output is correct
4 Correct 226 ms 9680 KB Output is correct
5 Correct 256 ms 9680 KB Output is correct
6 Incorrect 210 ms 9680 KB Output isn't correct
7 Halted 0 ms 0 KB -