Submission #372918

# Submission time Handle Problem Language Result Execution time Memory
372918 2021-03-02T09:43:57 Z Jarif_Rahman Stations (IOI20_stations) C++17
0 / 100
6 ms 1364 KB
#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int n;
vector<vector<int>> v;
vector<int> label(int nn, int k, vector<int> aa, vector<int> bb){
    n = nn;
    v.assign(n, {});
    for(int i = 0; i < n-1; i++){
        v[aa[i]].pb(bb[i]);
        v[bb[i]].pb(aa[i]);
    }
    vector<int> lb(n);
    for(int i = 0; i < n; i++) lb[i] = i;
    return lb;
}
vector<int> cur;
int ans;
void dfs(int nd, int ss, int tt){
    if(nd == tt){
        ans = cur.front();
        return;
    }
    if(ans != -1) return;
    for(int x: v[nd]) if(x!=ss){
        cur.pb(x);
        dfs(x, nd, tt);
        cur.pop_back();
    }
}
int find_next_station(int s, int t, vector<int> c){
    cur.clear();
    ans = -1;
    dfs(s, -1, t);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 992 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1120 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1244 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 864 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1364 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -