답안 #319945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
319945 2020-11-06T21:43:55 Z nickmet2004 기지국 (IOI20_stations) C++14
0 / 100
3000 ms 2097156 KB
#include<bits/stdc++.h>
#include "stations.h"
using namespace std;
const int N = 100005;
int n;
vector<int> adj[N] , R;
int tin[N] , tout[N] , dtime;
void dfs(int u , int p = -1){
    R[u] =tin[u] = dtime++;

    for(int v : adj[u]){
        if(v==p)continue;
        dfs(v  ,u);
    }
    tout[u]= dtime;
}
vector<int> label(int n , int k ,vector<int> u , vector<int> v){
    for(int i = 0; i < n; ++i) adj[i].clear();
    for(int i = 0; i < n; ++i) adj[u[i]].emplace_back(v[i]) , adj[v[i]].emplace_back(u[i]);
    R.resize(n);
    dfs(0);
    return R;
}
bool cmp(int a, int b){
    return tin[a] > tin[b];
}
int find_next_station(int s , int t , vector<int> c){
    sort(c.begin() , c.end() , cmp);
    for(int u : c){
        if(u <= t && t <= u) return u;
    }
    if(s <= t && t <= s) return s;
    return c[c.size()-1];
}
/*
int main (){
    cin >> n;
    for(int i =1; i < n; ++i){
        int u , v; cin >> u>> v;
        adj[u].emplace_back(v); adj[v].emplace_back(u);
    }
    vector<int> k = label(n , 1 , {3} , {3});
    cout << find_next_station(1 , 3 , {3 , 2 ,0}) << endl;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2664 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 5484 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3132 ms 1020264 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 958 ms 5516 KB Output is correct
2 Runtime error 6 ms 5228 KB Execution killed with signal 6 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 5484 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -