답안 #406375

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
406375 2021-05-17T13:44:56 Z bipartite_matching 기지국 (IOI20_stations) C++14
5 / 100
1220 ms 656 KB
#include <bits/stdc++.h>

#define forint(i, N) for (int i = 0; i < (N); i++)

using namespace std;

vector<int> value;
vector<bool> visited;

int minval = 0;

void go(vector< vector<int> >& graph, int n, bool odd) {

	visited[n] = true;

	if (odd) {
		for (auto& i : graph[n]) {
			if (!visited[i]) {
				go(graph, i, !odd);
			}
		}
		value[n] = minval;
		minval++;
	}
	else {
		value[n] = minval;
		minval++;
		for (auto& i : graph[n]) {
			if (!visited[i]) {
				go(graph, i, !odd);
			}
		}
	}
	
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector< vector<int> > graph(n);

	minval = 0;

	visited.clear();
	visited.resize(n);
	fill(visited.begin(), visited.end(), false);

	value.clear();
	value.resize(n);
	fill(value.begin(), value.end(), -1);

	forint(i, n - 1) {
		graph[u[i]].push_back(v[i]);
		graph[v[i]].push_back(u[i]);
	}

	go(graph, 0, true);

	return value;
}

int find_next_station(int s, int t, vector<int> c) {

	if (c.size() == 1) {
		return c[0];
	}
	
	
	if (s < c[0]) {
		if (t < s || t > c[c.size() - 1]) {
			return c[c.size() - 1];
		}

		if (t <= c[0]) {
			return c[0];
		}
	}
	else {
		if (t > s || t < c[0]) {
			return c[0];
		}
		if (t >= c[c.size() - 1]) {
			return c[c.size() - 1];
		}
	}


	int left = 0;
	int right = c.size() - 1;

	while (left + 1 < right) {
		if (t == c[left] || t == c[right]) {
			return t;
		}

		int mid = (left + right) / 2;
		if (t <= c[mid]) {
			right = mid;
		}
		else {
			left = mid;
		}

	}
	if (s < c[0]) {
		return c[right];
	}
	return c[left];
	
	
	/*
	if (s < c[0]) {
		if (t < s || t > c[c.size() - 1]) {
			return c[c.size() - 1];
		}
		forint(i, c.size()) {
			if (c[i] >= t) {
				return c[i];
			}
		}
	}
	else {
		if (t > s || t < c[0]) {
			return c[0];
		}
		for (int i = c.size() - 1; i >= 0; i--) {
			if (t >= c[i]) {
				return c[i];
			}
		}
	}
	*/
}
# 결과 실행 시간 메모리 Grader output
1 Correct 661 ms 612 KB Output is correct
2 Correct 583 ms 612 KB Output is correct
3 Correct 1144 ms 500 KB Output is correct
4 Correct 877 ms 400 KB Output is correct
5 Correct 910 ms 400 KB Output is correct
6 Correct 679 ms 564 KB Output is correct
7 Correct 689 ms 492 KB Output is correct
8 Correct 4 ms 468 KB Output is correct
9 Correct 7 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 601 ms 480 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 840 ms 504 KB Output is correct
2 Correct 674 ms 596 KB Output is correct
3 Correct 1220 ms 400 KB Output is correct
4 Correct 861 ms 400 KB Output is correct
5 Correct 740 ms 400 KB Output is correct
6 Correct 547 ms 528 KB Output is correct
7 Correct 567 ms 528 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 6 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Incorrect 664 ms 612 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1180 ms 400 KB Output is correct
2 Correct 850 ms 484 KB Output is correct
3 Correct 685 ms 492 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 6 ms 468 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 661 ms 488 KB Output is correct
8 Correct 1103 ms 464 KB Output is correct
9 Correct 854 ms 400 KB Output is correct
10 Correct 700 ms 400 KB Output is correct
11 Incorrect 5 ms 468 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 633 ms 612 KB Output is correct
2 Correct 567 ms 656 KB Output is correct
3 Correct 1039 ms 652 KB Output is correct
4 Correct 772 ms 400 KB Output is correct
5 Correct 772 ms 484 KB Output is correct
6 Correct 521 ms 492 KB Output is correct
7 Correct 600 ms 492 KB Output is correct
8 Correct 2 ms 476 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 2 ms 476 KB Output is correct
11 Incorrect 568 ms 488 KB Wrong query response.
12 Halted 0 ms 0 KB -