답안 #336669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
336669 2020-12-16T10:07:32 Z cheeheng 기지국 (IOI20_stations) C++14
5 / 100
970 ms 1120 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> AdjList[1005];
int dist[1005];

void dfs(int i, int k){
    if(dist[i] != -1){return;}
    dist[i] = k;
    for(int v: AdjList[i]){
        if(dist[v] == -1){
            dfs(v, k+1);
            return;
        }
    }
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);

	for(int i = 0; i < n; i ++){
        AdjList[i].clear();
	}

	int s = -1;
	memset(dist, -1, sizeof(dist));

	for(int i = 0; i < n-1; i ++){
        AdjList[u[i]].push_back(v[i]);
        AdjList[v[i]].push_back(u[i]);
	}

	for(int i = 0; i < n; i ++){
        if(AdjList[i].size() == 1){
            s = i;
            break;
        }
	}

	//dist[s] = 0;
    dfs(s, 0);

	for (int i = 0; i < n; i++) {
		labels[i] = dist[i];
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    //printf("s=%d t=%d\n", s, t);
    assert(s != t);

    if(s < t){
        return s+1;
    }else{
        return s-1;
    }

    /*for(int i = 1; i < 11; i ++){
        if(s == (t>>i)){
            return (t>>(i-1));
        }
    }

	return s>>1;*/
}
# 결과 실행 시간 메모리 Grader output
1 Correct 578 ms 892 KB Output is correct
2 Correct 427 ms 1016 KB Output is correct
3 Correct 899 ms 948 KB Output is correct
4 Correct 691 ms 864 KB Output is correct
5 Correct 677 ms 864 KB Output is correct
6 Correct 475 ms 892 KB Output is correct
7 Correct 548 ms 864 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
9 Correct 4 ms 736 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 364 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=4, label=-1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 552 ms 1072 KB Output is correct
2 Correct 420 ms 1120 KB Output is correct
3 Correct 877 ms 864 KB Output is correct
4 Correct 651 ms 864 KB Output is correct
5 Correct 641 ms 948 KB Output is correct
6 Correct 451 ms 892 KB Output is correct
7 Correct 477 ms 900 KB Output is correct
8 Correct 3 ms 948 KB Output is correct
9 Correct 5 ms 956 KB Output is correct
10 Correct 2 ms 864 KB Output is correct
11 Incorrect 1 ms 364 KB Invalid labels (values out of range). scenario=1, k=1000000, vertex=3, label=-1
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 956 ms 884 KB Output is correct
2 Correct 753 ms 864 KB Output is correct
3 Correct 661 ms 864 KB Output is correct
4 Correct 3 ms 864 KB Output is correct
5 Correct 5 ms 736 KB Output is correct
6 Correct 2 ms 776 KB Output is correct
7 Incorrect 1 ms 364 KB Invalid labels (values out of range). scenario=0, k=1000000000, vertex=2, label=-1
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 662 ms 1020 KB Output is correct
2 Correct 511 ms 1020 KB Output is correct
3 Correct 970 ms 992 KB Output is correct
4 Correct 616 ms 948 KB Output is correct
5 Correct 584 ms 948 KB Output is correct
6 Correct 438 ms 892 KB Output is correct
7 Correct 495 ms 748 KB Output is correct
8 Correct 3 ms 956 KB Output is correct
9 Correct 6 ms 776 KB Output is correct
10 Correct 2 ms 956 KB Output is correct
11 Incorrect 4 ms 364 KB Invalid labels (values out of range). scenario=0, k=1000000000, vertex=4, label=-1
12 Halted 0 ms 0 KB -