QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#525386#1139. Stationszhoukangyang#0 38ms4064kbC++172.1kb2024-08-20 15:56:222024-08-20 15:56:23

Judging History

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

  • [2024-08-20 15:56:23]
  • 评测
  • 测评结果:0
  • 用时:38ms
  • 内存:4064kb
  • [2024-08-20 15:56:22]
  • 提交

stations

#include<bits/stdc++.h>
// #include"stations.h"
// #define DEBUG
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long 
#define sz(a) ((int) (a).size())
#define pb emplace_back
#define me(a, x) memset(a, x, sizeof(a))
#define vi vector<int>
#define ull unsigned long long
using namespace std;
const int N = 1 << 21, mod = 1e9 + 7;
vi label(int n, int k, vi u, vi v) {
	vi deg(n);
	L(i, 0, n - 2) deg[u[i]] += 1, deg[v[i]] += 1;
	int root = 0;
	L(i, 0, n - 1) if(deg[i] == 1) root = i;
	vi fa(n, -1);
	vector<vi>e(n);
	vi dep(n);
	L(i, 0, n - 2)e[u[i]].pb(v[i]),e[v[i]].pb(u[i]);
	vi dfn(n), en(n);
	int idt = 0;
	function<void(int)>dfs=[&](int x) ->void {
		dfn[x]=++idt;
		for(auto&v:e[x])if(v!=fa[x]){
			fa[v]=x,dep[v]=dep[x]+1,dfs(v);
		}
		en[x]=idt;
	};
	dfs(0);
	vector<vi>ls(n+1),rs(n+1);
	L(i, 0, n - 1){
		if(dep[i] & 1) {
			// cout<<i<<" use"<<dfn[i]<<endl;
			ls[dfn[i]].pb(i);
		} else {
			// cout<<i<<" use "<<en[i]<<endl;
			rs[en[i]].pb(i);
		}
	}
	int top = 0;
	vi ans(n);
	L(i, 0, n) {
		sort(ls[i].begin(), ls[i].end(), [&] (int x, int y) {
			return dep[x] < dep[y];
		});
		sort(rs[i].begin(), rs[i].end(), [&] (int x, int y) {
			return dep[x] > dep[y];
		});
		for(auto&u : ls[i]) 
			ans[u] = ++top;
		for(auto&u : rs[i]) 
			ans[u] = ++top;
	}
	return ans;
}
int find_next_station(int s, int t, vi c) {
	if(sz(c) == 1) return c[0];
	sort(c.begin(), c.end());
	if(c[0] < s) {
		if(c[1] <= t && t <= s) {
			R(i, sz(c) - 1, 0) {
				if(c[i] <= t) {
					return c[i];
				}
			}
		} 
		return c[0];
	} else {
		if(s <= t && t <= c[sz(c) - 2]) {
			L(i, 0, sz(c) - 1) {
				if(t <= c[i]) {
					return c[i];
				}
			}
		} 
		return c[sz(c) - 2];
	}
}
// int main() {
// 	ios :: sync_with_stdio(false);
// 	cin.tie(0); cout.tie(0);
// 	auto lab = label(5, 10, vi{0, 1, 1, 2}, vi{1, 2, 3, 4});
// 	for(auto u : lab)cout << u << ' ';
// 	cout << endl;
// 	cout << "nxt_1 = " << find_next_station(1, 2, vi{3, 4, 5}) << endl;
// 	return 0;
// }

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 36ms
memory: 3800kb

input:

0
10
10 1000
4 5
9 0
2 6
5 2
8 3
1 4
8 1
6 0
3 7
3 1000
0 1
1 2
998 1000
166 178
393 452
389 179
622 429
892 866
872 18
899 227
835 637
587 769
504 386
369 577
65 441
523 17
803 221
878 321
637 892
696 473
16 146
840 322
495 986
353 275
330 585
831 402
719 810
704 830
780 940
53 901
894 911
394 482
...

output:

10
10
4
9
5
8
3
2
6
7
1
3
3
1
2
998
998
221
27
104
853
699
292
294
176
167
274
374
150
503
803
143
333
972
767
369
541
399
890
453
906
464
748
626
698
947
6
529
510
460
619
279
880
56
684
563
237
113
263
98
950
591
987
57
296
868
403
40
564
821
815
561
112
178
242
873
209
668
49
231
189
130
148
28
8...

input:

1
59784
2 1 1
1
843 799 2
574
575
2 1 1
1
152 690 2
848
849
2 3 1
3
1 2 1
2
2 1 1
1
675 266 2
742
743
3 4 2
1
2
4 1 1
1
526 584 2
474
475
2 9 2
9
10
196 529 2
223
224
66 600 2
934
935
113 796 2
732
733
715 563 2
285
286
2 1 1
1
77 94 2
69
70
1 2 2
2
3
2 1 1
1
569 156 2
647
648
1 2 1
2
571 745 2
37
3...

output:

1
575
1
848
3
2
1
742
1
1
474
9
223
934
732
286
1
69
2
1
647
2
37
1
1
301
3
2
2
868
23
139
3
2
53
2
14
20
3
1
2
677
29
609
28
449
712
370
527
66
1
564
850
3
1
1
3
802
1
9
2
2
119
651
532
40
177
3
2
68
158
982
714
2
629
335
1
3
850
1
3
138
1
520
1
35
919
846
2
2
2
1
46
8
3
437
627
135
1
225
605
687
2...

result:

wrong answer Diff at 8-th number: read 742 but expected 743

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 24ms
memory: 3804kb

input:

0
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 ...

output:

996
996
1
512
256
511
767
995
2
129
257
384
513
640
768
895
65
128
192
255
320
383
447
510
576
639
703
766
831
894
958
994
3
34
66
97
130
161
193
224
258
289
321
352
385
416
448
479
514
545
577
608
641
672
704
735
769
800
832
863
896
927
959
979
18
33
49
64
81
96
112
127
145
160
176
191
208
223
239
...

input:

1
50252
729 375 1
730
852 145 1
854
987 523 1
985
409 400 1
411
857 216 1
858
421 924 1
423
707 713 1
708
434 778 1
435
715 753 3
712
713
714
864 478 3
867
870
878
993 15 1
991
599 143 3
593
597
598
782 516 1
783
403 925 1
404
291 996 1
293
71 147 1
73
867 934 3
864
865
866
289 310 3
304
319
320
361...

output:

730
854
985
411
858
423
708
435
712
870
991
593
783
404
293
73
864
319
363
963
938
867
715
130
378
918
212
761
686
896
926
879
776
363
296
508
612
783
303
462
848
411
984
897
408
42
162
694
843
131
162
371
925
56
833
959
335
941
624
225
680
903
190
445
867
652
478
104
269
215
754
694
603
89
895
768
...

result:

wrong answer Diff at 10-th number: read 870 but expected 878

Subtask #3:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 28ms
memory: 3872kb

input:

0
10
2 1000000
1 0
997 1000000
830 513
223 672
727 200
763 415
581 440
34 42
267 325
912 693
753 59
401 289
198 641
982 214
41 49
453 107
940 806
905 732
153 482
248 405
102 79
480 837
534 620
564 856
679 178
278 247
899 206
333 672
297 308
407 863
26 752
272 178
204 603
208 10
715 562
785 285
184 5...

output:

2
2
1
997
997
126
214
575
36
714
263
146
674
846
330
807
875
549
622
636
900
872
23
955
81
243
773
219
778
917
529
470
554
200
983
853
38
694
303
188
666
751
823
511
907
79
562
118
70
570
404
385
253
786
728
808
715
499
713
497
905
465
305
358
571
580
558
432
7
964
176
937
464
318
863
578
843
433
85...

input:

1
59859
1 3 2
5
10
1 2 1
2
1 2 1
2
16 43 2
984
985
900 849 2
194
195
868 569 2
135
136
2 1 1
1
9 10 2
6
7
939 836 2
61
62
2 1 1
1
2 1 1
1
1 2 1
2
1 2 2
2
3
980 777 2
880
881
186 107 2
814
815
256 252 2
744
745
2 6 2
4
5
2 1 1
1
147 252 2
717
718
92 17 2
23
24
723 710 2
280
281
240 665 2
854
855
941 ...

output:

5
2
2
984
195
136
1
6
62
1
1
2
2
880
814
744
4
1
717
23
281
854
919
939
2
358
625
539
1
3
566
5
730
1
2
3
317
837
604
2
677
537
948
678
4
1
507
228
536
2
933
1
817
709
48
26
1
90
2
2
1
1
1
78
142
584
88
1
840
8
866
274
73
1
218
3
480
623
2
74
1
534
260
1
1
785
1
235
1
347
38
8
1
1
913
2
1
1
245
1
54...

result:

wrong answer Diff at 15-th number: read 814 but expected 815

Subtask #4:

score: 0
Wrong Answer

Test #34:

score: 10
Accepted
time: 38ms
memory: 3780kb

input:

0
10
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
0 1

output:

2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1

input:

1
100000
1 2 1
2
2 1 1
1
2 1 1
1
1 2 1
2
2 1 1
1
1 2 1
2
1 2 1
2
1 2 1
2
1 2 1
2
1 2 1
2
2 1 1
1
1 2 1
2
2 1 1
1
1 2 1
2
2 1 1
1
2 1 1
1
2 1 1
1
1 2 1
2
1 2 1
2
2 1 1
1
1 2 1
2
2 1 1
1
2 1 1
1
1 2 1
2
1 2 1
2
2 1 1
1
2 1 1
1
1 2 1
2
2 1 1
1
2 1 1
1
1 2 1
2
1 2 1
2
1 2 1
2
1 2 1
2
1 2 1
2
2 1 1
1
1 2...

output:

2
1
1
2
1
2
2
2
2
2
1
2
1
2
1
1
1
2
2
1
2
1
1
2
2
1
1
2
1
1
2
2
2
2
2
1
2
1
2
2
2
1
1
2
1
1
1
1
2
2
1
1
2
2
2
1
1
2
1
1
2
1
1
2
2
2
1
2
1
1
1
1
1
1
2
1
2
1
1
1
2
2
2
2
1
2
2
1
2
1
1
2
1
1
1
2
2
2
1
1
1
2
1
2
2
1
2
1
2
1
1
2
2
1
2
2
2
1
1
1
2
2
2
1
1
2
2
1
1
1
2
1
2
1
2
1
1
1
1
2
2
2
2
1
2
2
1
2
2
2
...

result:

ok 

Test #35:

score: 0
Wrong Answer
time: 38ms
memory: 4064kb

input:

0
10
3 1000000000
2 1
2 0
3 1000000000
1 0
2 0
3 1000000000
2 0
0 1
3 1000000000
0 2
1 2
3 1000000000
1 2
1 0
3 1000000000
1 0
2 1
3 1000000000
0 2
1 2
3 1000000000
1 2
1 0
3 1000000000
0 2
1 0
3 1000000000
2 0
1 2

output:

3
3
2
1
3
3
1
2
3
3
2
1
3
3
2
1
3
3
1
2
3
3
1
2
3
3
2
1
3
3
1
2
3
3
2
1
3
3
2
1

input:

1
75069
1 2 2
2
3
3 1 2
1
2
3 2 1
1
3 2 1
1
1 3 1
3
3 2 1
1
2 1 1
1
1 3 2
2
3
1 2 1
3
1 2 2
2
3
1 2 2
2
3
2 3 1
1
1 2 2
2
3
1 2 2
2
3
2 3 1
1
3 2 1
1
1 3 2
2
3
3 1 2
1
2
3 1 1
1
2 1 1
1
1 2 2
2
3
1 2 2
2
3
1 3 1
3
2 1 1
1
3 1 1
1
2 3 1
1
3 1 1
1
1 3 1
3
2 3 1
1
1 3 2
2
3
1 2 2
2
3
3 1 2
1
2
1 3 2
2
...

output:

2
1
1
1
3
1
1
2
3
2
2
1
2
2
1
1
2
1
1
1
2
2
3
1
1
1
1
3
1
2
2
1
2
1
3
1
2
1
1
3
1
1
3
1
2
2
2
1
3
2
1
2
2
1
2
2
1
1
3
1
2
1
1
2
3
2
3
1
2
1
2
1
1
1
2
1
2
3
3
1
3
3
1
3
2
2
2
2
1
2
1
1
1
2
2
1
2
2
2
1
3
3
1
2
3
2
2
1
1
2
2
1
1
2
1
1
2
1
1
1
2
3
1
1
3
1
2
1
2
2
1
2
1
3
2
1
1
2
1
1
3
1
1
1
3
3
3
1
1
1
...

result:

wrong answer Diff at 8-th number: read 2 but expected 3

Subtask #5:

score: 0
Wrong Answer

Test #54:

score: 0
Wrong Answer
time: 36ms
memory: 3732kb

input:

0
10
3 1000000000
1 0
2 1
998 1000000000
928 443
90 795
55 379
957 417
759 300
960 136
309 858
833 370
228 827
876 955
619 365
15 108
243 388
54 925
141 894
272 634
0 989
600 346
380 277
350 113
326 613
975 946
660 98
34 538
220 864
9 585
185 860
458 424
509 14
22 275
109 872
153 233
76 834
972 736
...

output:

3
3
1
2
998
998
932
260
459
562
134
417
633
210
836
113
757
220
742
784
542
117
140
639
178
907
45
476
382
389
173
93
576
284
419
231
575
412
510
831
971
880
740
500
243
198
850
619
532
373
822
630
708
972
46
961
166
886
177
996
952
713
369
25
5
290
772
873
753
925
167
415
695
820
507
196
14
580
544...

input:

1
59797
3 2 2
1
2
494 447 2
266
267
1 2 1
2
49 81 2
64
65
381 704 2
107
108
1 4 2
3
4
1 2 2
3
4
939 791 2
262
263
716 515 2
770
771
361 436 2
782
783
2 1 1
1
252 256 2
508
509
199 563 2
561
562
227 324 2
974
975
1 3 2
2
3
238 539 2
905
906
258 459 2
742
743
94 87 2
19
20
7 6 2
5
6
88 323 2
912
913
5...

output:

2
267
2
64
107
3
3
263
770
782
1
508
561
974
2
905
742
20
6
912
471
2
1
962
95
453
660
854
428
1
2
893
954
1
9
91
156
885
41
2
1
1
871
211
2
324
348
446
970
7
1
93
270
2
4
378
223
1
870
1
2
862
9
3
699
433
1
518
372
12
8
234
901
67
88
526
2
538
609
76
1
137
1
1
5
67
153
896
1
1
45
1
7
720
2
1
493
33...

result:

wrong answer Diff at 4-th number: read 64 but expected 65