Submission #42383

# Submission time Handle Problem Language Result Execution time Memory
42383 2018-02-26T15:30:45 Z dqhungdl 버스 (JOI14_bus) C++14
0 / 100
187 ms 14912 KB
#include <bits/stdc++.h>
using namespace std;

struct data
{
    int u,v,s,t;
};

typedef pair<int,int> ii;
data Edge[300005];
int n,m,T;
vector<ii> g[100005];

bool cmp(data x1,data x2)
{
    return x1.t<x2.t;
}

int Binary(int u,int t)
{
    int rs=-1,l=0,r=g[u].size()-1;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(g[u][mid].first<=t)
        {
            rs=g[u][mid].second;
            l=mid+1;
        }
        else
            r=mid-1;
    }
    return rs;
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("TEST.INP","r",stdin);
    cin>>n>>m;
    for(int i=1;i<=m;i++)
        cin>>Edge[i].u>>Edge[i].v>>Edge[i].s>>Edge[i].t;
    sort(Edge+1,Edge+m+1,cmp);
    for(int i=1;i<=m;i++)
        if(Edge[i].u==1)
            g[Edge[i].v].push_back(ii(Edge[i].t,Edge[i].s));
        else
        {
            int t=Binary(Edge[i].u,Edge[i].s);
            if(t!=-1)
            {
                ii tmp=ii(Edge[i].t,max(t,g[Edge[i].v].back().second));
                g[Edge[i].v].push_back(tmp);
            }
        }
    cin>>T;
    int val;
    while(T--)
    {
        cin>>val;
        cout<<Binary(n,val)<<"\n";
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 5112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5288 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 187 ms 14776 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 182 ms 14912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -