Submission #964627

# Submission time Handle Problem Language Result Execution time Memory
964627 2024-04-17T08:31:27 Z irmuun Stations (IOI20_stations) C++17
0 / 100
3000 ms 2097152 KB
#include<bits/stdc++.h>
#include "stations.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

const int N=1e3+5;
vector<int>adj[N],tin(N),tout(N),dep(N);
int cur=0;
void dfs(int x,int p){
    tin[x]=cur++;
    for(auto y:adj[x]){
        if(y!=p){
            dep[y]=dep[x]+1;
            dfs(y,x);
        }
    }
    tout[x]=cur++;
}

vector<int>label(int n,int k,vector<int>u,vector<int>v){
    for(int i=0;i<n-1;i++){
        adj[u[i]].pb(v[i]);
        adj[v[i]].pb(u[i]);
    }
    dfs(0,-1);
    vector<int>l(n);
    for(int i=0;i<n;i++){
        if(dep[i]%2==0){
            l[i]=tin[i];
        }
        else{
            l[i]=tout[i];
        }
    }
    return l;
}
 
int find_next_station(int s,int t,vector<int>c){
    if(s<c[0]){
        int l=s+1;
        for(int i=0;i<(int)c.size()-1;i++){
            if(l<=t&&t<=c[i]){
                return c[i];
            }
            l=c[i]+1;
        }
        return c.back();
    }
    else{
        int r=s-1;
        for(int i=(int)c.size()-1;i>0;i--){
            if(c[i]<=t&&t<=r){
                return c[i];
            }
            r=c[i]-1;
        }
        return c[0];
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 2416 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3058 ms 548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1549 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 550 ms 980 KB Output is correct
2 Runtime error 1185 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2116 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -