답안 #1035292

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035292 2024-07-26T08:54:18 Z Gray 기지국 (IOI20_stations) C++17
8 / 100
608 ms 772 KB
#include "stations.h"
#include <iostream>
#include <vector>

#define ll int
#define ff first
#define ss second
#define ln "\n"
#define pll pair<ll, ll>

using namespace std;


vector<vector<ll>> A;

void dfs(ll u, ll p, vector<ll> &labels){
	ll add=0;
	for (auto v:A[u]){
		if (v==p) continue;
		labels[v]=(labels[u]<<1ll)+add;
		add++;
		dfs(v, u, labels);
	}
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	A.clear();
	A.resize(n);
	for (ll i=0; i<n-1; i++){
		A[u[i]].push_back(v[i]);
		A[v[i]].push_back(u[i]);
	}
	vector<int> labels(n);
	labels[0]=1;
	dfs(0, 0, labels);
	// for (ll i=0; i<n; i++){
	// 	cout << labels[i] << ln;
	// }
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	ll cnts=0, cntt=0;
	for (ll i=0; i<=10; i++){
		if ((1ull<<i)&s){
			cnts=i;
		}
		if ((1ull<<i)&t){
			cntt=i;
		}
	}
	// cout << s << "->" << t << ":" << cnts << "&" <<cntt << ln;
	if (cnts>cntt){
		return c[0];
	}else if (cntt>cnts){
		if ((t^(s<<(cntt-cnts)))>>(cntt-cnts)==0){
			// cout << "Hap\n";
			if ((t&(1ll<<(cntt-cnts-1)))){
				return c[c.size()-1];
			}else{
				if (c.size()==3)return c[c.size()-2];
				else if (s==1){
					return c[0];
				}
				else return c[c.size()-1];
			}
		}else{
			return c[0];
		}
	}else{
		return c[0];
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 600 KB Invalid labels (duplicates values). scenario=2, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 287 ms 688 KB Output is correct
2 Correct 353 ms 684 KB Output is correct
3 Correct 608 ms 684 KB Output is correct
4 Correct 449 ms 684 KB Output is correct
5 Correct 411 ms 684 KB Output is correct
6 Correct 286 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 600 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 582 ms 684 KB Output is correct
2 Correct 421 ms 684 KB Output is correct
3 Correct 363 ms 684 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 2 ms 764 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 341 ms 772 KB Output is correct
8 Correct 478 ms 768 KB Output is correct
9 Correct 391 ms 684 KB Output is correct
10 Correct 354 ms 684 KB Output is correct
11 Incorrect 0 ms 344 KB Invalid labels (duplicates values). scenario=2, label=4
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -