QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#525369#1139. Stationszhoukangyang#0 0ms3932kbC++172.1kb2024-08-20 15:51:552024-08-20 15:51:56

Judging History

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

  • [2024-08-20 15:51:56]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3932kb
  • [2024-08-20 15:51:55]
  • 提交

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 dfn[x] < dfn[y];
		});
		sort(rs[i].begin(), rs[i].end(), [&] (int x, int y) {
			return en[x] < en[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(3, 5, vi{1, 2}) << endl;
// 	return 0;
// }

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3932kb

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:

0 use 10
1 use7
2 use 10
3 use9
4 use 10
5 use5
6 use3
7 use 10
8 use 10
9 use2
10
6
4
7
5
8
3
2
9
10
1
0 use 3
1 use2
2 use 3
3
2
1
3
0 use 998
1 use224
2 use54
3 use208
4 use 998
5 use 998
6 use366
7 use370
8 use 219
9 use 219
10 use330
11 use530
12 use 219
13 use788
14 use 998
15 use 219
16 use44...

input:

1
-1
0

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/channel_2_answer.txt)

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 0ms
memory: 3604kb

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:

0 use 996
1 use2
2 use513
3 use 257
4 use 512
5 use 768
6 use 996
7 use4
8 use131
9 use259
10 use386
11 use515
12 use642
13 use770
14 use897
15 use 67
16 use 130
17 use 194
18 use 257
19 use 322
20 use 385
21 use 449
22 use 512
23 use 578
24 use 641
25 use 705
26 use 768
27 use 833
28 use 896
29 use...

input:

1
-1
0

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/channel_2_answer.txt)

Subtask #3:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 0ms
memory: 3660kb

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:

0 use 2
1 use2
2
2
1
0 use 997
1 use252
2 use428
3 use 864
4 use72
5 use 864
6 use526
7 use292
8 use 864
9 use 864
10 use660
11 use 864
12 use887
13 use 864
14 use 864
15 use 864
16 use937
17 use881
18 use46
19 use 997
20 use162
21 use486
22 use 864
23 use438
24 use 864
25 use971
26 use 864
27 use 8...

input:

1
-1
0

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/channel_2_answer.txt)

Subtask #4:

score: 0
Wrong Answer

Test #34:

score: 0
Wrong Answer
time: 0ms
memory: 3708kb

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:

0 use 2
1 use2
2
2
1
0 use 2
1 use2
2
2
1
0 use 2
1 use2
2
2
1
0 use 2
1 use2
2
2
1
0 use 2
1 use2
2
2
1
0 use 2
1 use2
2
2
1
0 use 2
1 use2
2
2
1
0 use 2
1 use2
2
2
1
0 use 2
1 use2
2
2
1
0 use 2
1 use2
2
2
1

input:

1
-1
0

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/channel_2_answer.txt)

Subtask #5:

score: 0
Wrong Answer

Test #54:

score: 0
Wrong Answer
time: 0ms
memory: 3712kb

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:

0 use 3
1 use2
2 use 3
3
2
1
3
0 use 998
1 use 998
2 use317
3 use715
4 use921
5 use 204
6 use631
7 use 998
8 use217
9 use 998
10 use 204
11 use 998
12 use237
13 use 998
14 use 998
15 use881
16 use 204
17 use 204
18 use 998
19 use 204
20 use 998
21 use90
22 use749
23 use561
24 use575
25 use 204
26 us...

input:

1
-1
0

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/channel_2_answer.txt)