QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#179935#7249. Jimi Hendrixmendicillin2#AC ✓44ms25588kbC++171.9kb2023-09-15 13:46:292023-09-15 13:46:29

Judging History

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

  • [2023-09-15 13:46:29]
  • 评测
  • 测评结果:AC
  • 用时:44ms
  • 内存:25588kb
  • [2023-09-15 13:46:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

template <class T> int sz(T&& a) { return int(size(forward<T>(a))); }

template <class T> using vc = vector<T>;
template <class T> using vvc = vc<vc<T>>;

using ll = int64_t;
using vi = vc<int>;

template <class F>
struct ycr {
	F f;
	
	template <class T>
	explicit ycr(T&& f_) : f(forward<T>(f_)) {}

	template <class... Args>
	decltype(auto) operator()(Args&&... args) {
		return f(ref(*this), forward<Args>(args)...);
	}
};
template <class F>
decltype(auto) yc(F&& f) {
	return ycr<decay_t<F>>(forward<F>(f));
}

const int N=5e5+5;
int n,m;
char c[N];
struct node{
	int to,last;
	char ch;
}tree[N*2];
int ss=1,head[N];
inline void add(int from,int to,char ch)
{
	tree[++ss].to=to;
	tree[ss].ch=ch;
	tree[ss].last=head[from];
	head[from]=ss;
}
int f1[N],f2[N];
int p1[N],p2[N];
inline void dfs(int from,int x)
{
	//cout<<from<<" "<<x<<" "<<"yes"<<endl;
	p1[x]=p2[x]=x;
	for(int i=head[x];i;i=tree[i].last)
	{
		int k=tree[i].to;
		if(k==from) continue;
		dfs(x,k);
		if(f1[k]+(tree[i].ch==c[f1[k]+1])>f1[k])
		{
			f1[k]=f1[k]+(tree[i].ch==c[f1[k]+1]);
		}
		if(f2[k]-(tree[i].ch==c[f2[k]-1])<f2[k])
		{
			f2[k]=f2[k]-(tree[i].ch==c[f2[k]-1]);
		}
		if(f1[x]+1>=f2[k])
		{
			cout<<p1[x]<<" "<<p2[k]<<"\n";
			exit(0);
		}
		if(f1[k]+1>=f2[x])
		{
			cout<<p1[k]<<" "<<p2[x]<<"\n";
			exit(0);
		}
		if(f1[k]>f1[x]) f1[x]=f1[k], p1[x]=p1[k];
		if(f2[k]<f2[x]) f2[x]=f2[k], p2[x]=p2[k];
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	cout << fixed << setprecision(20);
	cin>>n>>m;
	for(int i=1;i<=n;i++) f2[i]=m+1;
	int u,v;
	char ch;
	for(int i=1;i<=n-1;i++) 
	{
		cin>>u>>v>>ch;
		add(u,v,ch); add(v,u,ch);
	}
	cin>>(c+1);
	c[0]=c[m+1]='+';
	dfs(0,1);
	//for(int i=1;i<=n;i++) cout<<f1[i]<<" "<<f2[i]<<endl;
	cout<<"-1 -1"<<"\n";
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7720kb

input:

9 3
1 2 a
2 3 b
2 4 a
4 5 b
4 6 c
6 7 d
6 8 a
8 9 b
acb

output:

8 5

result:

ok Both jury and contestant have lovely and correct paths :)

Test #2:

score: 0
Accepted
time: 2ms
memory: 11920kb

input:

2 1
1 2 b
b

output:

1 2

result:

ok Both jury and contestant have lovely and correct paths :)

Test #3:

score: 0
Accepted
time: 2ms
memory: 11920kb

input:

2 1
1 2 k
p

output:

-1 -1

result:

ok no path at all :)

Test #4:

score: 0
Accepted
time: 0ms
memory: 9756kb

input:

10 2
1 4 a
7 5 c
1 9 a
10 1 c
7 10 c
8 2 c
7 8 b
5 3 c
8 6 b
cb

output:

2 6

result:

ok Both jury and contestant have lovely and correct paths :)

Test #5:

score: 0
Accepted
time: 1ms
memory: 7764kb

input:

10 5
6 1 c
7 6 a
7 8 c
6 5 c
7 3 c
6 9 c
8 4 c
7 2 b
5 10 b
cbaca

output:

-1 -1

result:

ok no path at all :)

Test #6:

score: 0
Accepted
time: 0ms
memory: 9756kb

input:

10 3
3 10 c
1 9 b
4 8 a
10 4 b
2 3 c
7 6 a
8 5 b
5 1 a
6 2 c
bab

output:

5 10

result:

ok Both jury and contestant have lovely and correct paths :)

Test #7:

score: 0
Accepted
time: 0ms
memory: 9824kb

input:

10 5
9 1 c
5 4 c
1 7 a
3 9 c
8 5 a
2 6 b
4 10 a
7 8 a
6 3 a
cabab

output:

-1 -1

result:

ok no path at all :)

Test #8:

score: 0
Accepted
time: 1ms
memory: 9836kb

input:

10 2
9 10 c
9 8 c
9 3 c
9 4 c
9 1 a
9 2 a
9 5 c
9 7 b
9 6 b
ac

output:

2 5

result:

ok Both jury and contestant have lovely and correct paths :)

Test #9:

score: 0
Accepted
time: 1ms
memory: 7792kb

input:

10 2
10 3 c
10 4 b
10 8 b
10 1 a
10 7 c
10 5 b
10 2 c
10 9 c
10 6 b
ac

output:

1 9

result:

ok Both jury and contestant have lovely and correct paths :)

Test #10:

score: 0
Accepted
time: 1ms
memory: 7764kb

input:

10 2
6 7 e
6 9 l
6 2 q
6 10 i
6 3 s
6 4 e
6 5 l
6 1 z
6 8 g
zl

output:

1 5

result:

ok Both jury and contestant have lovely and correct paths :)

Test #11:

score: 0
Accepted
time: 2ms
memory: 9884kb

input:

10 2
4 1 s
4 6 y
4 9 p
4 2 t
4 7 c
4 8 m
4 3 v
4 10 n
4 5 d
mj

output:

-1 -1

result:

ok no path at all :)

Test #12:

score: 0
Accepted
time: 1ms
memory: 7788kb

input:

1000 11
987 593 b
428 821 a
865 116 b
676 817 a
409 769 a
594 200 a
74 401 b
488 529 b
401 114 b
903 124 a
920 385 b
379 739 b
302 624 b
55 127 a
257 667 b
548 282 b
285 725 b
400 776 b
885 285 b
24 695 b
656 552 b
554 118 a
316 531 b
659 187 a
925 333 a
944 409 b
856 44 a
585 646 b
527 831 a
634 77...

output:

897 819

result:

ok Both jury and contestant have lovely and correct paths :)

Test #13:

score: 0
Accepted
time: 1ms
memory: 7780kb

input:

1000 10
782 148 a
498 256 a
389 269 a
156 291 b
781 770 a
533 986 b
625 826 b
725 732 a
181 620 b
575 505 b
68 257 b
381 466 a
94 598 b
145 424 b
179 623 a
787 387 a
665 568 a
708 281 a
962 97 b
808 953 a
209 288 b
992 356 a
80 688 a
371 86 a
510 678 a
448 378 b
805 189 a
496 501 b
189 172 b
137 294...

output:

652 229

result:

ok Both jury and contestant have lovely and correct paths :)

Test #14:

score: 0
Accepted
time: 2ms
memory: 9836kb

input:

1000 20
657 328 a
185 518 a
778 343 b
56 390 a
755 62 b
128 399 a
925 968 a
624 991 a
692 392 a
874 657 b
204 49 a
808 587 a
819 122 a
778 138 a
719 7 a
402 357 a
28 767 a
355 689 b
124 889 a
972 443 b
809 172 b
207 308 a
750 296 a
205 933 b
449 978 b
887 777 b
220 287 a
150 387 a
394 803 a
209 532 ...

output:

-1 -1

result:

ok no path at all :)

Test #15:

score: 0
Accepted
time: 1ms
memory: 7780kb

input:

1000 10
555 641 a
309 489 b
799 943 b
934 662 a
929 754 b
682 680 a
935 474 b
476 739 a
227 800 a
152 462 a
238 466 b
38 181 a
355 424 b
22 512 a
37 693 a
190 957 a
560 636 b
219 349 b
912 266 b
473 105 b
706 458 b
505 978 a
916 645 b
524 699 a
748 160 b
855 643 b
408 446 b
764 28 b
997 373 a
391 27...

output:

23 201

result:

ok Both jury and contestant have lovely and correct paths :)

Test #16:

score: 0
Accepted
time: 0ms
memory: 11864kb

input:

1000 6
161 816 b
25 712 b
540 233 b
980 204 c
853 990 b
863 464 c
362 706 a
837 934 a
893 324 a
803 844 c
435 375 a
437 107 c
564 733 c
706 966 a
305 793 c
816 51 a
37 168 b
419 835 b
437 996 b
603 359 b
268 243 c
553 949 a
524 876 c
373 606 b
493 133 a
555 470 b
934 447 c
243 528 a
201 877 b
840 34...

output:

89 142

result:

ok Both jury and contestant have lovely and correct paths :)

Test #17:

score: 0
Accepted
time: 2ms
memory: 9844kb

input:

1000 635
163 159 o
615 797 x
192 770 n
211 860 j
274 227 m
1000 855 e
890 84 j
342 103 d
138 635 n
788 315 w
535 728 m
704 364 y
859 947 y
102 658 l
128 61 o
411 71 v
650 347 c
371 486 f
631 211 o
215 393 p
906 920 i
496 766 b
807 654 u
828 951 y
351 57 i
845 39 a
919 597 x
205 909 f
74 164 e
259 70...

output:

650 134

result:

ok Both jury and contestant have lovely and correct paths :)

Test #18:

score: 0
Accepted
time: 0ms
memory: 9856kb

input:

1000 191
370 983 e
792 207 u
260 334 t
504 718 t
379 287 a
323 706 a
591 418 k
350 514 s
933 566 c
680 498 k
723 141 x
872 182 e
634 156 n
155 23 o
86 824 k
953 716 l
772 379 m
769 527 g
818 266 u
790 874 n
764 408 f
497 607 k
77 34 i
967 935 s
10 656 x
865 446 t
485 32 s
233 916 r
547 196 r
640 99 ...

output:

-1 -1

result:

ok no path at all :)

Test #19:

score: 0
Accepted
time: 0ms
memory: 9856kb

input:

1000 40
471 594 o
345 995 n
973 405 y
215 646 o
297 617 f
964 831 t
737 920 z
412 883 j
666 375 h
520 441 n
461 496 d
491 541 g
397 568 v
584 171 q
137 843 k
795 173 d
598 99 x
393 888 f
852 718 b
559 545 x
887 55 x
639 293 k
459 47 v
876 42 j
708 381 y
178 984 r
698 666 l
709 286 i
328 608 g
808 8 ...

output:

467 218

result:

ok Both jury and contestant have lovely and correct paths :)

Test #20:

score: 0
Accepted
time: 0ms
memory: 9860kb

input:

1000 100
151 902 a
730 935 b
295 369 b
823 145 a
783 673 a
15 642 a
218 190 b
171 976 a
688 444 a
58 447 b
492 542 b
453 653 b
363 805 a
28 893 b
398 911 b
990 121 a
634 646 a
501 52 b
62 655 b
294 533 b
86 21 a
375 453 a
95 54 a
399 739 b
805 151 b
478 152 a
447 656 b
462 481 a
598 965 b
765 663 b
...

output:

513 960

result:

ok Both jury and contestant have lovely and correct paths :)

Test #21:

score: 0
Accepted
time: 0ms
memory: 9896kb

input:

1000 2
660 306 n
660 778 l
660 924 y
660 902 n
660 947 m
660 514 u
660 656 f
660 696 l
660 220 t
660 543 h
660 721 p
660 699 l
660 998 r
660 999 p
660 197 r
660 244 w
660 670 x
660 444 c
660 878 n
660 359 z
660 297 r
660 840 m
660 354 c
660 851 s
660 958 v
660 182 h
660 28 a
660 764 f
660 681 f
660 ...

output:

470 101

result:

ok Both jury and contestant have lovely and correct paths :)

Test #22:

score: 0
Accepted
time: 0ms
memory: 9852kb

input:

1000 2
526 579 a
526 150 b
526 168 a
526 24 b
526 754 a
526 128 b
526 277 a
526 38 b
526 171 a
526 759 b
526 627 a
526 205 b
526 380 b
526 242 a
526 621 b
526 771 b
526 70 a
526 838 b
526 973 a
526 399 b
526 768 a
526 431 a
526 75 a
526 6 b
526 192 b
526 880 a
526 988 b
526 155 b
526 559 a
526 617 a...

output:

725 977

result:

ok Both jury and contestant have lovely and correct paths :)

Test #23:

score: 0
Accepted
time: 18ms
memory: 16796kb

input:

200000 2
140844 190697 r
140844 124115 f
140844 112461 i
140844 19992 d
140844 562 u
140844 76432 r
140844 108370 l
140844 152075 h
140844 31083 d
140844 61854 b
140844 45032 v
140844 132457 f
140844 63601 x
140844 82506 k
140844 73325 s
140844 73164 c
140844 85132 x
140844 139963 j
140844 197978 v
...

output:

169806 132738

result:

ok Both jury and contestant have lovely and correct paths :)

Test #24:

score: 0
Accepted
time: 19ms
memory: 16700kb

input:

200000 2
105421 5980 b
105421 150207 a
105421 115929 a
105421 77625 b
105421 143936 b
105421 95634 a
105421 110294 a
105421 49972 a
105421 24373 a
105421 193010 a
105421 19866 b
105421 1118 a
105421 118386 a
105421 130614 a
105421 24993 b
105421 88211 b
105421 68550 b
105421 21014 b
105421 173180 a
...

output:

73106 171813

result:

ok Both jury and contestant have lovely and correct paths :)

Test #25:

score: 0
Accepted
time: 42ms
memory: 25128kb

input:

200000 50000
38207 51908 a
123390 86325 b
123134 78235 b
104677 7330 a
164321 59342 a
114414 23189 b
106625 88215 a
59088 195055 a
172888 140745 b
57801 157900 a
101730 162191 a
108109 115360 a
138612 131239 b
42283 137960 b
164553 189592 b
78817 8055 a
149496 65780 b
123519 83239 b
73624 42402 a
15...

output:

188870 24792

result:

ok Both jury and contestant have lovely and correct paths :)

Test #26:

score: 0
Accepted
time: 39ms
memory: 25588kb

input:

200000 150000
116487 13268 b
84833 43815 b
40993 188837 a
197098 131672 a
86374 646 b
7675 76552 a
24652 50027 b
124373 179046 b
187714 153729 a
50044 199894 a
84749 13439 b
82858 132467 a
166035 157002 a
101852 162914 a
99617 11130 b
165361 67801 b
420 99312 a
192080 40459 b
87669 172467 b
148401 1...

output:

-1 -1

result:

ok no path at all :)

Test #27:

score: 0
Accepted
time: 41ms
memory: 24800kb

input:

200000 5000
6663 37269 l
74938 58143 w
79955 85205 e
172041 175241 z
72980 56678 k
130529 39531 f
81405 82349 k
167653 189863 m
125916 165194 c
115521 94123 d
144413 171450 r
164197 60490 v
101177 12501 u
105194 47575 w
159149 59610 z
26237 151798 o
173544 184018 y
161141 47378 u
107975 73932 o
1143...

output:

173498 142940

result:

ok Both jury and contestant have lovely and correct paths :)

Test #28:

score: 0
Accepted
time: 30ms
memory: 24080kb

input:

200000 10000
162365 187926 o
25849 45282 n
69475 76654 d
59397 127873 g
37833 30216 s
83354 97719 l
3541 153207 w
50314 49894 d
137478 114846 y
29318 82901 b
21404 175703 a
187463 35667 u
58966 76623 s
180628 39038 g
113093 198767 s
91990 70450 u
107164 61047 v
54197 32854 m
116445 68673 n
143665 92...

output:

-1 -1

result:

ok no path at all :)

Test #29:

score: 0
Accepted
time: 23ms
memory: 18336kb

input:

200000 4736
135910 152433 b
196857 44930 b
180142 58474 b
123198 131735 a
135761 103949 b
141761 134977 a
155058 106175 b
159734 152651 a
127918 80018 a
158348 128224 a
190962 27731 a
163214 124362 b
166917 136629 b
97804 18952 a
96266 167594 b
18232 163601 b
169573 142485 b
117278 55875 b
194424 18...

output:

45138 1192

result:

ok Both jury and contestant have lovely and correct paths :)

Test #30:

score: 0
Accepted
time: 39ms
memory: 23120kb

input:

200000 54739
116541 156209 b
112813 171247 b
134494 179457 b
52303 59188 b
153997 36467 a
109126 136699 b
69996 174599 a
161141 167775 a
80734 55539 a
64447 151228 a
96031 39205 b
158968 109675 b
114262 198088 b
37743 110411 a
136504 159933 a
194559 108431 a
169372 118023 b
22893 12888 a
178554 2486...

output:

112439 102951

result:

ok Both jury and contestant have lovely and correct paths :)

Test #31:

score: 0
Accepted
time: 40ms
memory: 23160kb

input:

200000 49999
117084 195231 a
38504 191202 n
134618 132918 i
24748 150597 v
13448 127058 i
177923 81154 p
121381 39626 k
94945 87355 a
90130 158970 d
81311 340 b
38299 12558 f
64359 134940 x
122699 198894 o
141100 37956 t
74043 99225 w
114816 94553 s
93452 175194 q
100356 164608 q
116087 132226 w
155...

output:

35200 64824

result:

ok Both jury and contestant have lovely and correct paths :)

Test #32:

score: 0
Accepted
time: 28ms
memory: 17160kb

input:

200000 20
56534 21846 a
127466 99775 b
197009 10481 a
13071 25861 a
166610 159584 c
183696 180211 a
194823 177576 a
153464 114447 b
140204 180986 c
10953 80685 c
93501 197669 a
76092 77696 a
20469 146483 b
55141 60548 b
185727 72248 c
108679 64141 b
85966 116285 a
15265 80076 c
104480 159095 a
13971...

output:

185625 72481

result:

ok Both jury and contestant have lovely and correct paths :)

Test #33:

score: 0
Accepted
time: 28ms
memory: 17176kb

input:

200000 18
25645 115335 b
138086 169629 b
147195 28130 a
90251 19229 b
30594 31008 a
27226 35388 c
68202 86317 a
194817 75123 c
38191 107787 a
178085 179255 a
74069 151441 c
105178 75948 a
28810 1591 b
163582 190803 a
56418 65635 b
195649 161994 b
58484 137644 a
112226 112900 a
103924 124258 b
105408...

output:

82829 54293

result:

ok Both jury and contestant have lovely and correct paths :)

Test #34:

score: 0
Accepted
time: 23ms
memory: 18288kb

input:

200000 15
130040 52065 a
85066 121947 a
142587 138972 c
98852 109707 b
96892 2991 c
172776 101526 b
83451 129580 a
178186 309 a
38893 86923 c
112506 116926 b
76377 20365 b
89708 124927 a
7264 167237 b
45646 137740 c
22215 42553 a
5329 40199 c
198538 98200 b
150068 35954 b
166666 83706 a
50329 174345...

output:

198828 115474

result:

ok Both jury and contestant have lovely and correct paths :)

Test #35:

score: 0
Accepted
time: 29ms
memory: 16396kb

input:

200000 13
186972 158038 n
141304 144334 c
150644 92260 d
75472 56494 e
93402 188990 e
112663 24786 y
143123 110084 s
193393 150706 a
106848 187386 y
44009 68354 j
12608 93048 d
48143 18749 f
143466 41123 i
81541 68422 l
146792 94023 n
14630 175762 l
132789 8074 g
39339 8042 n
188748 141794 i
68662 1...

output:

165959 188304

result:

ok Both jury and contestant have lovely and correct paths :)

Test #36:

score: 0
Accepted
time: 28ms
memory: 16308kb

input:

200000 22
77116 177355 b
41248 8511 a
196560 61055 b
93074 47152 b
169708 95466 a
131881 56210 a
21420 196316 b
71574 64537 b
160186 59468 a
69818 109482 a
58057 78908 a
39465 120639 b
90762 32564 b
183259 54839 b
153491 3146 a
97991 105451 b
134392 128070 a
80498 54279 b
163777 40692 a
54306 48475 ...

output:

66844 154552

result:

ok Both jury and contestant have lovely and correct paths :)

Test #37:

score: 0
Accepted
time: 28ms
memory: 17180kb

input:

200000 24
12092 977 b
89606 92554 a
98999 130713 b
29359 58778 a
86536 37639 a
15061 4119 b
36547 117055 b
22860 158815 a
110179 178511 a
154100 151668 b
13203 121088 a
165548 85502 b
115992 126319 b
145360 95284 a
118922 97769 b
41847 136764 b
28626 108733 b
27254 112889 a
199417 167610 a
71426 109...

output:

107892 10392

result:

ok Both jury and contestant have lovely and correct paths :)

Test #38:

score: 0
Accepted
time: 24ms
memory: 18292kb

input:

200000 32
42678 46956 a
85804 92343 a
58647 187834 a
40022 25789 a
192593 53904 a
62580 127220 b
187438 105756 a
87640 82998 b
26525 55475 a
87118 195308 b
94195 84584 a
82645 34745 b
69349 68405 a
165586 5950 a
52040 129106 a
125053 154281 b
4517 168318 a
26041 152380 b
15689 105515 b
78761 63223 b...

output:

66362 83806

result:

ok Both jury and contestant have lovely and correct paths :)

Test #39:

score: 0
Accepted
time: 38ms
memory: 16244kb

input:

200000 37
97344 4860 b
59032 105557 b
33232 135880 a
41849 198146 b
181848 110519 b
51642 92621 b
62698 122657 b
32849 87091 a
159582 163613 b
128647 193411 a
175141 65234 b
197376 169970 a
173293 29975 b
154234 146457 a
197603 41093 a
38428 81295 a
34669 118482 a
182546 102545 b
170110 18443 a
1652...

output:

-1 -1

result:

ok no path at all :)

Test #40:

score: 0
Accepted
time: 36ms
memory: 16124kb

input:

200000 35
165160 188580 b
169019 179034 a
162600 167716 b
12953 68090 b
51469 169831 b
84126 106165 b
111483 188669 a
152506 68223 a
537 174015 b
43219 40560 a
197797 163869 a
39536 107449 a
185560 9974 a
180844 103851 b
60717 196032 a
3018 76453 b
84013 144864 a
7327 117846 a
63880 44504 a
1058 108...

output:

34556 152796

result:

ok Both jury and contestant have lovely and correct paths :)

Test #41:

score: 0
Accepted
time: 34ms
memory: 18240kb

input:

200000 36
25981 130203 b
96700 180125 a
127368 165961 b
64857 173799 b
198299 114900 b
165661 69893 a
106889 72173 b
33234 70283 a
115642 167905 b
196064 12610 a
189624 198367 a
69593 172980 a
87807 44725 b
107139 88268 a
113674 93210 b
195408 109671 a
106735 41427 a
2199 82781 b
30091 21737 a
17002...

output:

125942 25928

result:

ok Both jury and contestant have lovely and correct paths :)

Test #42:

score: 0
Accepted
time: 38ms
memory: 18912kb

input:

200000 37
84272 141200 a
115974 60401 b
164159 9233 b
95061 109295 a
179482 54983 a
25267 76584 a
148283 2711 a
195061 101251 b
112375 127613 a
109313 75729 a
82914 177997 b
80961 97278 b
130197 40832 a
168014 1782 b
20599 181600 b
171303 78907 a
125250 138469 a
114909 25905 b
139958 146457 a
173471...

output:

-1 -1

result:

ok no path at all :)

Test #43:

score: 0
Accepted
time: 29ms
memory: 18288kb

input:

200000 9
64062 160380 r
125886 155571 c
171774 169538 y
98278 87688 l
208 190495 o
74457 145357 j
56724 189110 f
10492 199625 z
146904 64638 a
148765 61665 n
182687 145016 v
179802 191980 c
101508 48680 k
69710 64219 v
143312 77676 q
34690 137264 k
175733 155735 q
164595 31504 p
143912 4344 v
165613...

output:

178549 26398

result:

ok Both jury and contestant have lovely and correct paths :)

Test #44:

score: 0
Accepted
time: 32ms
memory: 16240kb

input:

200000 10
180259 144845 g
116606 49642 c
17065 195194 h
19110 15737 w
67814 40604 p
199806 21161 h
198894 143075 h
152108 67120 x
102508 1974 q
165957 166081 z
149994 80176 q
5593 159358 r
13672 105895 p
2242 85983 c
195067 95657 n
100828 77916 z
28356 190852 w
35853 122208 w
53822 40137 h
191589 27...

output:

-1 -1

result:

ok no path at all :)

Test #45:

score: 0
Accepted
time: 23ms
memory: 17712kb

input:

200000 28
69795 159223 b
120740 49968 a
175591 112576 b
13475 97987 b
93853 116495 b
27796 20158 b
44515 110666 a
48486 93139 a
59784 172936 a
100761 56005 b
141115 12245 b
164341 15635 b
125415 76778 b
176918 178207 b
148171 27281 b
40709 87600 a
87479 119566 b
117375 963 a
175380 35918 b
139480 65...

output:

92966 60392

result:

ok Both jury and contestant have lovely and correct paths :)

Test #46:

score: 0
Accepted
time: 19ms
memory: 16104kb

input:

200000 29
196920 93284 b
10733 37080 b
60158 81484 a
182923 50537 a
44422 77822 b
10715 107731 a
159771 158288 a
141849 81541 a
188541 14047 a
119582 134888 a
108994 160081 b
115800 193600 b
173240 175337 a
61052 2216 b
94021 154781 a
105837 107609 a
53254 144636 b
152439 131027 a
98945 168837 b
100...

output:

118826 87415

result:

ok Both jury and contestant have lovely and correct paths :)

Test #47:

score: 0
Accepted
time: 23ms
memory: 16228kb

input:

200000 29
139335 36430 a
19077 167148 a
14826 196018 a
24497 91018 b
71 151469 b
43094 77328 b
78218 90406 a
42412 109730 a
57085 70444 b
99796 87016 b
101863 123386 b
43379 152650 b
80264 91368 b
174594 94358 a
157043 105781 b
28863 53814 b
100240 97159 a
68353 97147 a
160012 39855 a
101463 155647 ...

output:

158365 184446

result:

ok Both jury and contestant have lovely and correct paths :)

Test #48:

score: 0
Accepted
time: 34ms
memory: 18224kb

input:

200000 38
198494 65812 a
154023 48530 a
161230 125892 a
163972 48765 b
149921 34327 a
165256 90546 a
1100 143079 a
39141 162819 b
151463 155237 b
132570 183741 b
147521 184478 b
32509 68455 a
78349 36126 b
2191 85041 a
155104 15754 a
193739 16536 a
159913 14905 b
160205 140456 b
154269 149246 a
1820...

output:

-1 -1

result:

ok no path at all :)

Test #49:

score: 0
Accepted
time: 41ms
memory: 20268kb

input:

200000 100000
138756 91790 c
50567 42961 d
199463 59094 d
158218 93083 e
186890 197958 e
175585 130069 b
131469 8549 a
148305 145725 d
163309 126256 b
180382 170586 b
129874 146508 b
195775 126883 c
113925 170635 e
161858 116160 d
34505 49053 b
75227 124804 e
137697 81109 e
130130 16821 d
91088 1858...

output:

120276 158931

result:

ok Both jury and contestant have lovely and correct paths :)

Test #50:

score: 0
Accepted
time: 35ms
memory: 22536kb

input:

200000 100000
93749 174202 a
182960 2304 n
23460 111271 d
142390 124490 h
185012 131881 l
47738 185622 p
44434 156356 r
187212 128621 n
121124 15781 g
162845 94053 k
161568 149252 s
81413 147891 o
187595 35071 q
199280 137374 b
42071 173786 s
153686 41725 f
74389 182341 x
75787 187476 o
20106 74660 ...

output:

197101 82602

result:

ok Both jury and contestant have lovely and correct paths :)

Test #51:

score: 0
Accepted
time: 44ms
memory: 22412kb

input:

200000 50000
26351 4065 d
190076 154406 b
47708 176166 c
56748 94747 d
180672 11088 e
135472 172289 a
88952 10245 a
196982 12308 d
99292 19366 a
197043 157324 e
53458 64737 c
684 196026 e
152456 196571 b
118949 7102 e
156767 81095 b
11897 181274 a
60539 89314 b
160599 154426 a
6602 102026 c
74738 90...

output:

80847 166560

result:

ok Both jury and contestant have lovely and correct paths :)

Test #52:

score: 0
Accepted
time: 43ms
memory: 20484kb

input:

200000 50000
25937 89996 f
147254 157058 r
72097 126197 k
143403 116253 i
119674 154912 l
149128 99550 v
30203 6706 r
181413 186366 s
130563 55386 z
13331 114440 u
145968 41837 g
44820 114272 w
113675 55575 b
19773 51572 a
14228 195495 r
16293 151927 f
3957 130644 s
186545 136301 v
58146 38728 b
138...

output:

73950 125703

result:

ok Both jury and contestant have lovely and correct paths :)

Test #53:

score: 0
Accepted
time: 33ms
memory: 19224kb

input:

200000 1000
138872 149623 e
161260 117770 a
151105 54329 a
120464 187446 d
163266 199184 e
31632 92742 d
62677 81139 b
5465 164139 e
14679 132480 a
172929 74447 d
15984 111070 a
91677 94911 c
25320 189129 b
68296 188503 c
89958 121999 e
142233 61572 e
113297 20842 c
99998 177215 b
118327 120009 c
78...

output:

34366 57113

result:

ok Both jury and contestant have lovely and correct paths :)

Test #54:

score: 0
Accepted
time: 35ms
memory: 21812kb

input:

200000 1000
53986 146114 r
139076 142403 c
86688 88562 g
40058 165888 g
51103 110647 z
72526 152808 c
152872 151941 y
36322 136029 g
125522 52877 s
196754 146676 j
185946 69972 c
10245 171498 q
172902 143651 e
36856 6810 j
111006 64817 m
84264 71406 y
89432 35911 o
103603 52662 k
124703 96445 n
6390...

output:

140202 174034

result:

ok Both jury and contestant have lovely and correct paths :)

Extra Test:

score: 0
Extra Test Passed