답안 #416659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
416659 2021-06-02T17:54:35 Z Dilshod_Imomov 기지국 (IOI20_stations) C++17
76 / 100
1103 ms 55540 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 1e3 + 7;
 
void dfs( vector<vector<int>> adj, int v, int p, int h, vector<int> &lb, int &cnt ) {
	if ( h % 2 == 0 ) {
		lb[v] = cnt;
	}
	cnt++;
	for ( auto u: adj[v] ) {
		if ( u != p ) {
			dfs( adj, u, v, h + 1, lb, cnt );
		}
	}
	if ( h & 1 ) {
		lb[v] = cnt;
	}
	// cout << "-> " << v << " " << lb[v] << endl;
	cnt++;
}
 
 
vector<int> label(int n, int k, vector<int> U, vector<int> V) {
	vector < vector < int > > adj(n + 1);
	for ( int i = 0; i < n - 1; i++ ) {
		int u = U[i], v = V[i];
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	vector < int > lb(n);
	int cnt = 0;
	dfs( adj, 0, -1, 0, lb, cnt );
	return lb;
}
 
int find_next_station(int s, int t, vector<int> c) {
	int sz = c.size(), pr = -1;
	int tins = -1, touts = -1;
	vector < int > tin(sz), tout(sz);
	if ( c[0] > s ) { // s is in even layer, s in tin
		tins = s;
		if ( s == 0 ) {
			touts = c.back() + 1;
		}
		else {
			touts = c[sz - 2] + 1;
			pr = c.back();
			c.pop_back();
			sz--;
		}
		tin[0] = tins + 1;
		tout[0] = c[0];
		for ( int i = 1; i < sz; i++ ) {
			tin[i] = tout[i - 1] + 1;
			tout[i] = c[i];
		}
	}
	else { // s in odd layer
		touts = s;
		if ( sz == 1 ) {
			tins = s - 1;
			return c[0];
		}
		else {
			pr = c[0];
			c.erase(c.begin());
			sz--;
			tins = c[0] - 1;
		}
		tout[sz - 1] = s - 1;
		tin[sz - 1] = c[sz - 1];
		for ( int i = sz - 2; i >= 0; i-- ) {
			tout[i] = tin[i + 1] - 1;
			tin[i] = c[i];
		}
	}
	// cout << tins << ' ' << touts << ' ' << pr << endl;
	for ( int i = 0; i < sz; i++ ) {
		int u = c[i];
		// cout << tin[i] << " " << tout[i] << endl;
		if ( tin[i] <= t && tout[i] >= t ) {
			return u;
		}
	}
	assert( pr != -1 );
	return pr;
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:40:17: warning: variable 'touts' set but not used [-Wunused-but-set-variable]
   40 |  int tins = -1, touts = -1;
      |                 ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 294 ms 55344 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 521 ms 896 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 820 ms 55404 KB Output is correct
2 Correct 1094 ms 53168 KB Output is correct
3 Correct 814 ms 476 KB Output is correct
4 Correct 645 ms 488 KB Output is correct
5 Correct 630 ms 488 KB Output is correct
6 Correct 1085 ms 53596 KB Output is correct
7 Correct 530 ms 42632 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 2 ms 448 KB Output is correct
11 Correct 595 ms 400 KB Output is correct
12 Correct 1024 ms 54444 KB Output is correct
13 Correct 1069 ms 50116 KB Output is correct
14 Correct 517 ms 3148 KB Output is correct
15 Correct 60 ms 516 KB Output is correct
16 Correct 216 ms 632 KB Output is correct
17 Correct 575 ms 656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 869 ms 464 KB Output is correct
2 Correct 649 ms 400 KB Output is correct
3 Correct 630 ms 488 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 0 ms 476 KB Output is correct
7 Correct 618 ms 400 KB Output is correct
8 Correct 814 ms 476 KB Output is correct
9 Correct 675 ms 484 KB Output is correct
10 Correct 599 ms 412 KB Output is correct
11 Correct 6 ms 480 KB Output is correct
12 Correct 4 ms 472 KB Output is correct
13 Correct 3 ms 480 KB Output is correct
14 Correct 4 ms 468 KB Output is correct
15 Correct 2 ms 564 KB Output is correct
16 Correct 435 ms 488 KB Output is correct
17 Correct 496 ms 488 KB Output is correct
18 Correct 495 ms 488 KB Output is correct
19 Correct 498 ms 400 KB Output is correct
20 Correct 515 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 881 ms 55500 KB Partially correct
2 Partially correct 1044 ms 48752 KB Partially correct
3 Correct 897 ms 484 KB Output is correct
4 Correct 644 ms 400 KB Output is correct
5 Correct 625 ms 400 KB Output is correct
6 Partially correct 996 ms 55540 KB Partially correct
7 Partially correct 532 ms 31156 KB Partially correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 4 ms 476 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Partially correct 975 ms 1144 KB Partially correct
12 Partially correct 607 ms 1128 KB Partially correct
13 Correct 893 ms 400 KB Output is correct
14 Correct 710 ms 484 KB Output is correct
15 Correct 624 ms 564 KB Output is correct
16 Partially correct 552 ms 1004 KB Partially correct
17 Correct 583 ms 484 KB Output is correct
18 Partially correct 1076 ms 37404 KB Partially correct
19 Partially correct 1042 ms 51764 KB Partially correct
20 Partially correct 488 ms 4104 KB Partially correct
21 Correct 53 ms 420 KB Output is correct
22 Partially correct 217 ms 544 KB Partially correct
23 Partially correct 595 ms 852 KB Partially correct
24 Correct 6 ms 468 KB Output is correct
25 Correct 5 ms 468 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 4 ms 480 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 484 ms 528 KB Output is correct
30 Correct 527 ms 400 KB Output is correct
31 Correct 525 ms 400 KB Output is correct
32 Correct 487 ms 400 KB Output is correct
33 Correct 488 ms 492 KB Output is correct
34 Partially correct 869 ms 42000 KB Partially correct
35 Partially correct 1065 ms 55540 KB Partially correct
36 Partially correct 1035 ms 45916 KB Partially correct
37 Partially correct 1078 ms 13356 KB Partially correct
38 Partially correct 1103 ms 13616 KB Partially correct
39 Partially correct 1072 ms 17900 KB Partially correct
40 Partially correct 1008 ms 18000 KB Partially correct
41 Partially correct 1083 ms 14632 KB Partially correct
42 Partially correct 353 ms 664 KB Partially correct
43 Partially correct 599 ms 848 KB Partially correct
44 Partially correct 558 ms 1048 KB Partially correct
45 Partially correct 705 ms 1588 KB Partially correct
46 Partially correct 621 ms 13948 KB Partially correct
47 Partially correct 889 ms 26844 KB Partially correct
48 Partially correct 530 ms 1032 KB Partially correct
49 Partially correct 617 ms 1292 KB Partially correct