답안 #1073771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073771 2024-08-24T20:38:43 Z allin27x 기지국 (IOI20_stations) C++17
5 / 100
681 ms 936 KB
#include <bits/stdc++.h>
using namespace std;
#include "stations.h"

const int N = 1001;
vector<int> adj[N];
int tin[N];
int tout[N];
vector<int> order;

void dfs(int i, int p, int tp) {
	if (!tp) order.push_back(i);
	for (int c: adj[i]) {
		if (c == p) continue;
		dfs(c,i, !tp);
	}
	if (tp) order.push_back(i);
}

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

int find_next_station(int s, int t, std::vector<int> c) {
	if (s > c[0]) {
		// s is time-out, all neighbors are time-in
		// c[0] is the parent
		int n = c.size();
		vector<int> tout(n);
		for (int i=1; i<n-1; i++) {
			tout[i] = tin[i+1] - 1;
		}
		tout[n-1] = s;
		for (int i=1; i<n; i++) {
			if (c[i] <= t && t<=tout[i]) return c[i];
		}
		return c[0];
	} else {
		// s is time-in, all neighbors are time-out
		// c[n-1] is the parent
		int n = c.size();
		vector<int> tin(n);
		for (int i=n-2; i>0; i--) {
			tin[i] = c[i-1] + 1;
		}
		tin[0] = s;
		for (int i=0; i<n-1; i++) {
			if (tin[i] <= t && t<=c[i]) return c[i];
		}
		return c[n-1];
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 388 ms 684 KB Output is correct
2 Correct 282 ms 684 KB Output is correct
3 Correct 608 ms 684 KB Output is correct
4 Correct 451 ms 684 KB Output is correct
5 Correct 410 ms 684 KB Output is correct
6 Correct 350 ms 684 KB Output is correct
7 Correct 333 ms 684 KB Output is correct
8 Correct 2 ms 780 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 296 ms 680 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 389 ms 684 KB Output is correct
2 Correct 326 ms 684 KB Output is correct
3 Correct 681 ms 684 KB Output is correct
4 Correct 439 ms 684 KB Output is correct
5 Correct 383 ms 684 KB Output is correct
6 Correct 344 ms 684 KB Output is correct
7 Correct 324 ms 684 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 1 ms 764 KB Output is correct
11 Incorrect 384 ms 800 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 612 ms 684 KB Output is correct
2 Correct 493 ms 684 KB Output is correct
3 Correct 435 ms 684 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 776 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Incorrect 447 ms 684 KB Wrong query response.
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 317 ms 684 KB Output is correct
2 Correct 332 ms 684 KB Output is correct
3 Correct 657 ms 684 KB Output is correct
4 Correct 493 ms 684 KB Output is correct
5 Correct 405 ms 688 KB Output is correct
6 Correct 306 ms 684 KB Output is correct
7 Correct 301 ms 936 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Incorrect 301 ms 688 KB Wrong query response.
12 Halted 0 ms 0 KB -