QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#29304#1139. StationsQingyu0 0ms0kbC++201.3kb2022-04-16 22:31:242023-01-15 18:24:15

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-15 18:24:15]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2022-04-16 22:31:24]
  • 提交

stations

#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> sz, labels;
vector<vector<int>> E;
int dfsSiz(int x, int p = -1) {
	sz[x] = 1;
	for (int y : E[x]) {
		if (y == p) continue;
		sz[x] += dfsSiz(y, x);
	}
	return sz[x];
}
void dfs(int x, int s, int e, int p = -1, int h = 0) {
	if (h & 1) {
		labels[x] = e--;
	} else {
		labels[x] = s++;
	}
	for (int y : E[x]) {
		if (y == p) continue;
		dfs(y, s, s + sz[y] - 1, x, h + 1);
		s += sz[y];
	}
	assert(s == e + 1);
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	assert(u.size() == n - 1 && v.size() == n - 1);
	sz = vector<int>(n);
	labels = vector<int>(n);
	E = vector<vector<int>>(n);
	for (int i = 0; i < n - 1; ++i) {
		E[u[i]].push_back(v[i]);
		E[v[i]].push_back(u[i]);
	}
	dfsSiz(0);
	dfs(0, 0, n - 1);
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	while(1);
	vector<int> sub{s, s};
	int m = c.size();
	if (c[0] < s) {
		if (m > 1) sub[0] = c[1];
		if (t < sub[0] || t > sub[1]) return c[0];
		for (int i = 1; i + 1 < m; ++i)
			if (c[i + 1] > t) return c[i];
		return c[m - 1];
	} else {
		if (s != 0 && m > 1) sub[1] = c[m - 2];
		else if (s == 0) sub[1] = c[m - 1];
		if (t < sub[0] || t > sub[1]) return c[m - 1];
		for (int i = 0;; ++i)
			if (c[i] >= t) return c[i];
	}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Stage 2: Program stations Time Limit Exceeded

Test #1:

score: 0
Stage 2: Program stations Time Limit Exceeded

input:

10
10 1000
4 5
9 0
2 6
5 2
8 3
1 4
8 1
6 0
3 7
5575
4 6 5
7 3 3
6 0 0
8 5 1
7 1 3
0 4 6
0 5 6
0 8 6
1 6 4
4 5 5
4 8 1
4 3 1
8 9 1
4 8 1
2 7 5
4 6 5
6 9 0
6 9 0
8 0 1
7 2 3
1 0 4
1 8 8
7 2 3
6 8 2
6 8 2
9 6 0
6 0 0
0 9 9
2 5 5
9 6 0
2 0 6
0 9 9
2 9 6
3 6 8
2 0 6
0 1 6
5 8 4
1 2 4
1 6 4
3 6 8
6 4 2
0 ...

output:

10
0
7
2
6
3
8
9
5
4
1
3
0
2
1
998
0
995
192
115
363
517
924
922
43
52
942
842
69
713
413
76
883
244
449
847
675
817
326
763
310
752
468
590
518
269
213
687
706
756
597
937
336
163
532
653
979
106
953
121
266
625
229
162
920
348
813
179
652
395
401
655
107
41
974
343
10
548
170
985
30
89
71
191
388
...

input:


output:


result:


Subtask #2:

score: 0
Stage 2: Program stations Time Limit Exceeded

Test #11:

score: 0
Stage 2: Program stations Time Limit Exceeded

input:

10
996 1000
0 1
2 0
1 3
4 1
5 2
6 2
7 3
3 8
4 9
10 4
11 5
12 5
6 13
14 6
7 15
7 16
17 8
18 8
19 9
9 20
21 10
10 22
23 11
24 11
12 25
26 12
27 13
13 28
14 29
30 14
15 31
15 32
16 33
34 16
35 17
17 36
18 37
38 18
39 19
40 19
41 20
42 20
43 21
44 21
45 22
46 22
23 47
48 23
49 24
24 50
25 51
52 25
26 53...

output:

996
0
511
995
1
256
512
767
128
255
383
510
639
766
894
994
2
65
129
192
257
320
384
447
513
576
640
703
768
831
895
958
33
64
96
127
160
191
223
254
288
319
351
382
415
446
478
509
544
575
607
638
671
702
734
765
799
830
862
893
926
957
978
993
3
18
34
49
66
81
97
112
130
145
161
176
193
208
224
23...

input:


output:


result:


Subtask #3:

score: 0
Stage 2: Program stations Time Limit Exceeded

Test #17:

score: 0
Stage 2: Program stations Time Limit Exceeded

input:

10
2 1000000
1 0
10000
1 0 0
1 0 0
0 1 1
1 0 0
0 1 1
0 1 1
1 0 0
0 1 1
1 0 0
1 0 0
0 1 1
0 1 1
0 1 1
1 0 0
1 0 0
0 1 1
1 0 0
1 0 0
0 1 1
1 0 0
0 1 1
1 0 0
0 1 1
0 1 1
1 0 0
0 1 1
0 1 1
1 0 0
1 0 0
1 0 0
0 1 1
1 0 0
1 0 0
1 0 0
0 1 1
1 0 0
1 0 0
0 1 1
0 1 1
1 0 0
0 1 1
1 0 0
1 0 0
0 1 1
1 0 0
0 1 1
1...

output:

2
0
1
997
0
738
650
289
828
150
601
718
190
18
534
57
985
315
242
228
960
988
841
905
783
621
91
645
86
943
335
394
310
664
877
11
826
170
561
676
198
113
41
353
953
785
302
746
794
294
460
479
611
78
136
56
149
365
151
367
955
399
559
506
293
284
306
432
857
896
688
923
400
546
1
286
21
431
5
646
5...

input:


output:


result:


Subtask #4:

score: 0
Stage 2: Program stations Time Limit Exceeded

Test #34:

score: 0
Stage 2: Program stations Time Limit Exceeded

input:

10
2 1000000000
0 1
10000
0 1 1
1 0 0
0 1 1
0 1 1
0 1 1
0 1 1
0 1 1
0 1 1
0 1 1
0 1 1
1 0 0
0 1 1
0 1 1
1 0 0
1 0 0
0 1 1
1 0 0
0 1 1
1 0 0
1 0 0
0 1 1
1 0 0
1 0 0
1 0 0
1 0 0
1 0 0
0 1 1
1 0 0
0 1 1
1 0 0
1 0 0
1 0 0
0 1 1
0 1 1
0 1 1
1 0 0
1 0 0
1 0 0
1 0 0
1 0 0
0 1 1
1 0 0
0 1 1
1 0 0
1 0 0
0 1 ...

output:

2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1

input:


output:


result:


Subtask #5:

score: 0
Stage 2: Program stations Time Limit Exceeded

Test #54:

score: 0
Stage 2: Program stations Time Limit Exceeded

input:

10
3 1000000000
1 0
2 1
7507
1 2 2
2 0 1
1 2 2
1 2 2
1 2 2
0 2 1
0 2 1
2 1 1
2 1 1
0 2 1
1 0 0
1 0 0
1 0 0
2 0 1
1 0 0
0 1 1
0 1 1
0 2 1
2 0 1
2 0 1
2 0 1
0 2 1
2 0 1
1 0 0
2 0 1
0 1 1
2 0 1
1 2 2
2 0 1
0 2 1
0 2 1
0 2 1
0 2 1
2 0 1
0 1 1
2 0 1
0 1 1
0 2 1
0 2 1
2 0 1
2 0 1
1 2 2
0 2 1
2 0 1
2 0 1
2...

output:

3
0
2
1
998
0
269
941
742
639
70
784
568
991
365
91
444
981
459
417
659
87
64
562
26
294
159
725
819
812
31
111
625
917
782
970
626
789
691
370
230
321
461
701
958
6
351
582
669
828
379
571
493
229
158
240
38
315
27
205
249
488
832
179
199
911
429
328
448
276
37
786
506
381
694
8
190
621
657
419
883...

input:


output:


result: