답안 #307686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
307686 2020-09-29T05:25:06 Z CodePlatina 기지국 (IOI20_stations) C++14
0 / 100
912 ms 1272 KB
#include "stations.h"
#include <vector>

using namespace std;

vector<int> gph[1010];
int ord[1010];
int cnt = 0;

void dfs(int x)
{
    ord[x] = ++cnt;
    for(auto y : gph[x]) if(!ord[y]) dfs(y);
}

vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
	vector<int> labels(n);
	for(int i = 0; i < n; ++i) ord[i] = 0;
	cnt = 0;
	for(int i = 0; i < n - 1; ++i)
    {
        gph[u[i]].push_back(v[i]);
        gph[v[i]].push_back(u[i]);
    }
    dfs(0);
    for(int i = 0; i < n; ++i) labels[i] = ord[i];
    return labels;
}

int find_next_station(int s, int t, vector<int> c)
{
    int mn = (int)1e9, mn2 = (int)1e9;
    for(int x : c)
    {
        if(mn2 > x) swap(x, mn2);
        if(mn > mn2) swap(mn, mn2);
    }
    int n = (mn2 == (int)1e9 ? c[0] + 1 : mn2 - 1);
    if(s <= n && n <= t)
    {
        for(int x : c) if(n <= x && x <= t) return x;
    }
    else return mn;
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 1228 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 912 ms 768 KB Output is correct
2 Runtime error 2 ms 1140 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -