답안 #377816

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
377816 2021-03-15T07:55:06 Z autumn_eel 기지국 (IOI20_stations) C++14
5 / 100
1041 ms 1172 KB
#include "stations.h"
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<int(n);i++)
using namespace std;
typedef long long ll;

static vector<vector<int>>E;
static vector<int>labels;

void dfs(int v,int p,int l){
	labels[v]=l;
	for(int u:E[v]){
		if(u==p)continue;
		dfs(u,v,l+1);
	}
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v){
	E=vector<vector<int>>(n);
	labels=vector<int>(n);
	vector<int>deg(n);
	rep(i,n-1){
		E[u[i]].push_back(v[i]);
		E[v[i]].push_back(u[i]);
		deg[u[i]]++;
		deg[v[i]]++;
	}
	int s=max_element(deg.begin(),deg.end())-deg.begin();
	if(deg[s]==2){
		s=min_element(deg.begin(),deg.end())-deg.begin();
	}
	int x=1;
	for(int u:E[s]){
		dfs(u,s,x);
		x+=1000;
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(s==0){
		int nx=((s-1)/1000)*1000+1;
		return nx;
	}
	if((s-1)/1000==(t-1)/1000){
		return s<t?s+1:s-1;
	}
	if(s%1000==1)return 0;
	return s-1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 531 ms 976 KB Output is correct
2 Correct 440 ms 956 KB Output is correct
3 Correct 851 ms 756 KB Output is correct
4 Correct 642 ms 868 KB Output is correct
5 Correct 563 ms 884 KB Output is correct
6 Correct 481 ms 1032 KB Output is correct
7 Correct 510 ms 884 KB Output is correct
8 Correct 3 ms 868 KB Output is correct
9 Correct 5 ms 876 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 512 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=3, label=1001
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 624 ms 972 KB Output is correct
2 Correct 520 ms 1172 KB Output is correct
3 Correct 930 ms 868 KB Output is correct
4 Correct 682 ms 884 KB Output is correct
5 Correct 621 ms 756 KB Output is correct
6 Correct 498 ms 1032 KB Output is correct
7 Correct 419 ms 1012 KB Output is correct
8 Correct 3 ms 896 KB Output is correct
9 Correct 5 ms 736 KB Output is correct
10 Correct 1 ms 756 KB Output is correct
11 Incorrect 614 ms 736 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 964 ms 884 KB Output is correct
2 Correct 848 ms 756 KB Output is correct
3 Correct 685 ms 848 KB Output is correct
4 Correct 3 ms 736 KB Output is correct
5 Correct 5 ms 756 KB Output is correct
6 Correct 2 ms 868 KB Output is correct
7 Incorrect 579 ms 860 KB Wrong query response.
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 549 ms 884 KB Output is correct
2 Correct 411 ms 864 KB Output is correct
3 Correct 1041 ms 736 KB Output is correct
4 Correct 706 ms 868 KB Output is correct
5 Correct 698 ms 736 KB Output is correct
6 Correct 437 ms 864 KB Output is correct
7 Correct 451 ms 864 KB Output is correct
8 Correct 3 ms 916 KB Output is correct
9 Correct 5 ms 756 KB Output is correct
10 Correct 1 ms 868 KB Output is correct
11 Incorrect 5 ms 492 KB Invalid labels (duplicates values). scenario=0, label=3
12 Halted 0 ms 0 KB -