QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#88831#5828. 游戏FxorG20 131ms23120kbC++141.3kb2023-03-17 17:18:092023-03-17 17:18:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-17 17:18:12]
  • 评测
  • 测评结果:20
  • 用时:131ms
  • 内存:23120kb
  • [2023-03-17 17:18:09]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define pb push_back

const int N = 2e5 + 10;

int n, q;

vector<int> G[N];

inline int read() {
	
	int w = 1, s = 0; char c;
	while(!isdigit(c = getchar())) if(c == '-') w = -1;
	while(isdigit(c)) s = (s << 1) + (s << 3) + (c & 15), c = getchar();
	return s * w;
}

int topu, topv, dep[N], dept, fa[N], l[N], tot;

void dfs1(int u, int f, int flg) {
	
	dep[u] = dep[f] + 1; fa[u] = f;
	if(dep[u] > dept) {
		dept = dep[u];
		if(!flg) topu = u;
		else topv = u;
	} for(int v : G[u]) {
		if(v == f) continue;
		dfs1(v, u, flg);
	} return ;
}

inline void pre() {
	
	dfs1(1, 0, 0); dept = 0;
	for(int i = 1; i <= n; i ++ ) dep[i] = 0;
	dfs1(topu, 0, 1);
	int now = topv; l[++ tot] = now;
	while(fa[now]) now = fa[now], l[++ tot] = now;
	reverse(l + 1, l + tot + 1);
	return ;
}

int main() {
	
//	freopen("game.in", "r", stdin);
//	freopen("game.out", "w", stdout);
	n = read();
	for(int i = 1; i < n; i ++ ) {
		int u = read(), v = read();
		G[u].pb(v); G[v].pb(u);
	} pre();
	q = read();
	while(q -- ) {
		int x = read(), y = read(), z = read();
		if(x == y + z) printf("%d %d %d\n", topu, l[x + 1], l[y + 1]);
		else if(y == x + z) printf("%d %d %d\n", topu, l[x + 1], l[y + 1]);
		else if(z == x + y) printf("%d %d %d\n", l[x + 1], topu, l[z + 1]);
	}
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 8784kb

input:

500
279 196
182 105
400 14
278 217
198 411
379 318
120 421
314 95
437 325
23 433
71 485
192 154
90 224
180 71
328 93
183 101
404 349
223 285
492 100
366 480
29 328
200 448
365 156
226 231
129 167
246 273
171 452
284 6
131 471
229 90
480 48
448 157
240 221
7 36
401 200
255 438
436 110
281 489
388 258...

output:

50 360 366
50 125 110
50 202 120
30 50 165
454 50 350
17 50 68
50 201 281
50 390 320
50 239 436
50 120 132
50 452 110
298 50 290
50 361 28
480 50 429
298 50 227
454 50 28
50 298 120
50 366 171
50 68 253
50 28 62
50 436 60
298 50 240
50 179 50
125 50 30
50 366 132
50 346 470
50 461 165
50 152 54
248 ...

result:

wrong answer Wrong answer on test 1

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 9820kb

input:

2000
643 1871
689 23
1822 1443
1031 1027
1655 845
189 771
1561 498
19 1778
576 1080
904 717
1690 291
1387 1077
398 811
1310 1231
645 1291
480 927
330 170
1464 1057
1033 894
1308 288
1292 1529
1212 122
1108 401
89 1118
1058 1088
1764 1314
981 1255
1893 864
180 1887
1903 843
734 1412
883 1013
1739 124...

output:

641 44 1337
641 1400 1152
641 793 977
1329 641 659
641 1763 1351
1144 641 1917
1437 641 120
641 1264 1690
641 195 1351
501 641 1543
641 1425 469
1528 641 1366
641 1104 1147
641 1953 1480
641 909 1276
641 1338 1808
641 1810 809
291 641 1948
291 641 9
932 641 1852
641 359 682
438 641 690
641 1478 1400...

result:

wrong answer Wrong answer on test 2

Test #3:

score: 0
Wrong Answer
time: 87ms
memory: 15940kb

input:

200000
56968 132021
105656 107536
123627 58349
119191 138198
133708 142638
114350 24980
137784 40346
124158 130204
80684 183207
78156 94449
21893 157560
54464 73571
145830 57756
160288 32120
178632 142663
26565 185985
70576 24906
32217 115826
185756 137673
54280 179613
77826 144447
66005 29955
11745...

output:


result:

wrong output format Unexpected end of file - int32 expected

Test #4:

score: 0
Wrong Answer
time: 80ms
memory: 16240kb

input:

200000
41999 100683
85781 129266
122431 179332
162416 44814
24405 42267
154161 12483
178049 159964
67625 152391
133072 25866
178005 14695
94384 170290
54701 40323
66280 128515
159022 55057
14985 12920
182805 40659
173117 67973
99771 26102
198919 94543
23608 187601
61125 5759
89437 47647
18142 192402...

output:


result:

wrong output format Unexpected end of file - int32 expected

Test #5:

score: 0
Wrong Answer
time: 75ms
memory: 16056kb

input:

200000
195072 75458
31991 127114
60943 49502
186375 1130
45394 147217
168455 84307
132752 188952
101108 130004
107490 22003
16275 187645
111002 42669
138880 137115
112688 172751
81697 99037
166996 18495
2234 56119
170807 101349
105736 23180
148159 40863
136678 11849
190707 91245
61779 120740
157115 ...

output:


result:

wrong output format Unexpected end of file - int32 expected

Test #6:

score: 0
Wrong Answer
time: 83ms
memory: 16128kb

input:

200000
48556 78408
155026 9376
8983 61211
150393 85068
90892 109283
75746 89742
6760 187245
168658 130735
68602 127646
60802 149828
22898 59471
172845 100274
42303 190696
7612 134905
94702 59800
129633 192496
19903 64869
51318 63358
34692 66030
98535 176606
153647 177529
157903 147292
106273 107278
...

output:

14517 121306 15443

result:

wrong answer Wrong answer on test 1

Test #7:

score: 10
Accepted
time: 79ms
memory: 23120kb

input:

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

output:

200000 54356 117304
200000 170197 131241
200000 84517 105221
179889 200000 163219
200000 158370 164025
200000 113515 85385
143829 200000 85216
200000 122372 28132
200000 25711 157674
200000 179037 24813
200000 197101 57460
200000 139639 117928
200000 179418 195973
200000 106717 22762
200000 100818 1...

result:

ok Accepted!

Test #8:

score: 10
Accepted
time: 131ms
memory: 16136kb

input:

200000
5732 55198
128966 25317
114737 116391
150003 18274
43867 70745
76222 4169
55976 114951
198396 72896
38647 19711
12756 172119
73197 117994
117512 14177
130965 126990
119440 183341
142023 60829
111893 57350
122754 123305
36525 79077
36447 91967
135405 170456
165839 147481
66074 175822
22238 264...

output:

147752 147752 109303
147752 147752 48782
147752 147752 109094
147752 147752 4704
147752 147752 186222
147752 147752 25039
147752 147752 142021
147752 147752 8336
147752 147752 132321
147752 147752 115584
147752 147752 76788
147752 147752 3161
147752 147752 190443
147752 147752 29649
147752 147752 19...

result:

ok Accepted!

Test #9:

score: 0
Wrong Answer
time: 110ms
memory: 16280kb

input:

200000
185063 17064
180987 114492
88071 71803
158363 135918
60910 54848
97338 6734
192937 9410
49617 199068
82499 63554
188791 188152
178767 40866
11304 27212
144234 138097
42236 3946
103355 12683
50992 20598
145723 48620
11709 115688
123172 121379
70541 130844
147827 39431
139372 61280
42705 54015
...

output:

128603 116990 151852
131030 128603 167698
133896 128603 6620
81903 128603 129910
66571 128603 61141
128603 66457 123262
100184 128603 169006
88640 128603 76098
191762 128603 86757
52105 128603 58715
128603 92579 39740
128603 1129 165165
128603 73020 27765
128603 101757 115022
128603 78559 93144
1286...

result:

wrong answer Wrong answer on test 1

Test #10:

score: 0
Wrong Answer
time: 82ms
memory: 16184kb

input:

200000
197244 185999
18639 124754
154223 12099
53676 167616
22710 22294
150412 66132
19320 75478
170410 122661
130961 175554
171586 85572
188386 81238
120249 117687
43214 126266
8744 165654
164725 189519
124144 170329
86605 100197
130545 17030
113301 96665
67733 187286
37846 146399
75352 117550
3235...

output:

134958 109361 103769
109361 139608 68680
109361 39950 86057
109361 72608 61042
193867 109361 101302
109361 140316 37141
61893 109361 175169
109361 175474 30064
109361 198774 32800
109361 12417 178225
190389 109361 98895
109361 186968 42467
109361 7174 126878
109361 72827 15318
109361 90984 188656
10...

result:

wrong answer Wrong answer on test 1