답안 #580286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
580286 2022-06-21T03:16:19 Z pirhosig 기지국 (IOI20_stations) C++17
5 / 100
961 ms 712 KB
#include "stations.h"
#include <bits/stdc++.h>
#define  R(a) for (int i = 0; i < a; ++i)
#define RR(a) for (int j = 0; j < a; ++j)
using namespace std;



void name(vector<int> adj[], vector<int>& val, int& cont, bool even, int p, int n) {
	if (!even) val[n] = cont++;
	for (int a : adj[n]) {
		if (a != p) name(adj, val, cont, !even, n, a);
	}
	if (even) val[n] = cont++;
}




vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> adj[n];
	R(n - 1) {
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	vector<int> ret(n);
	int cont = 0;
	name(adj, ret, cont, false, -1, 0);
	// cerr << "L";
	// R(n) {
	// 	cerr << " " << ret[i];
	// }
	// cerr << endl;
	return ret;
}



int find_next_station(int s, int t, vector<int> c) {
	// cerr << "S " << s << " " << t << " " << c[0] << endl;
	int m = c.size();
	if (m == 1) return c[0];

	if (s == 0) {
		R(m) {
			if (c[i] >= t) return c[i];
		}
	}
	else {
		bool yea = true;
		for (int a : c) {
			if (a > s) {
				yea = false;
				break;
			}
		}
		if (yea) {
			// cerr << "V " << (c[0] < t) << (t < s) << endl;
			if (!(c[1] <= t && t < s)) return c[0];

			for (int i = 1; i < m - 1; ++i) {
				if (t < c[i + 1]) return c[i];
			}

			return c[m - 1];
		}
		else {
			if (s < t && t < c[m - 1]) {
				for (int i = m - 2; i >= 0; --i) {
					if (t <= c[i]) return c[i];
				}
			}
			return c[m - 1];
		}
	}

	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 488 ms 624 KB Output is correct
2 Correct 447 ms 664 KB Output is correct
3 Correct 961 ms 416 KB Output is correct
4 Correct 742 ms 416 KB Output is correct
5 Correct 555 ms 416 KB Output is correct
6 Correct 434 ms 544 KB Output is correct
7 Correct 448 ms 636 KB Output is correct
8 Correct 3 ms 492 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 421 ms 528 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 493 ms 632 KB Output is correct
2 Correct 445 ms 640 KB Output is correct
3 Correct 947 ms 416 KB Output is correct
4 Correct 665 ms 420 KB Output is correct
5 Correct 466 ms 420 KB Output is correct
6 Correct 427 ms 536 KB Output is correct
7 Correct 429 ms 624 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 3 ms 500 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
11 Correct 608 ms 572 KB Output is correct
12 Incorrect 403 ms 712 KB Wrong query response.
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 777 ms 508 KB Output is correct
2 Correct 627 ms 504 KB Output is correct
3 Correct 623 ms 508 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 5 ms 492 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 630 ms 420 KB Output is correct
8 Correct 865 ms 480 KB Output is correct
9 Correct 776 ms 484 KB Output is correct
10 Correct 687 ms 508 KB Output is correct
11 Incorrect 8 ms 492 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 496 ms 544 KB Output is correct
2 Correct 482 ms 636 KB Output is correct
3 Correct 936 ms 420 KB Output is correct
4 Correct 689 ms 504 KB Output is correct
5 Correct 585 ms 416 KB Output is correct
6 Correct 412 ms 616 KB Output is correct
7 Correct 417 ms 536 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 5 ms 500 KB Output is correct
10 Correct 1 ms 488 KB Output is correct
11 Incorrect 510 ms 536 KB Wrong query response.
12 Halted 0 ms 0 KB -