답안 #1080192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080192 2024-08-29T07:53:19 Z Faisal_Saqib 기지국 (IOI20_stations) C++17
10 / 100
645 ms 800 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+100;
const int M=1e3-1;
vector<int> ma[N];
int tin[N],tout[N],timer=-1;
void dfs(int v, int p)
{
    tin[v] = ++timer; // n

    for (auto u:ma[v]) {
        if (u != p)
            dfs(u, v);
    }

    tout[v] = timer; // n
}
bool is_ancestor(int u, int v)
{
	int tn=u/M;
	int tot=u%M + tn;
	int tn1=v/M;
	int tot1=v%M + tn1;
    return tn <= tn1 && tot >= tot1;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	timer=-1;
	for(int i=0;i<(n);i++)ma[i].clear();
	vector<int> labels(n,0);
	for(int i=0;i<(n-1);i++)
	{
		ma[u[i]].push_back(v[i]);
		ma[v[i]].push_back(u[i]);
	}
	dfs(0,-1);
	// tout[i] >= tin[i]
	// tout[i]-tin[i] == sz[i]
	// 1<= sz[i] <=n
	for(int i=0;i<n;i++)
		labels[i]=(tin[i]*M)+(tout[i]-tin[i]);
	return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
	if(is_ancestor(s,t))
	{
		for(auto k:c)
		{
			if(is_ancestor(s,k) and is_ancestor(k,t)){
				return k;
			}
		}
	}
	for(auto k:c)
		if(is_ancestor(k,s))
			return k;
	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=5997
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1509
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 381 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 645 ms 684 KB Output is correct
2 Correct 491 ms 684 KB Output is correct
3 Correct 390 ms 684 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 3 ms 776 KB Output is correct
6 Correct 0 ms 764 KB Output is correct
7 Correct 451 ms 800 KB Output is correct
8 Correct 637 ms 684 KB Output is correct
9 Correct 458 ms 684 KB Output is correct
10 Correct 414 ms 684 KB Output is correct
11 Correct 3 ms 768 KB Output is correct
12 Correct 3 ms 776 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 0 ms 776 KB Output is correct
16 Correct 356 ms 684 KB Output is correct
17 Correct 366 ms 684 KB Output is correct
18 Correct 310 ms 684 KB Output is correct
19 Correct 330 ms 684 KB Output is correct
20 Correct 337 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 354 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -