For problem statement at 1000-1999/1200-1299/1270-1279/1271/problemC.txt this is a correct solution, but verifier at 1000-1999/1200-1299/1270-1279/1271/verifierC.go ends with case 2 failed: expected "599\n606 159" got "599\n606 160"
input:
722 606 158
975 942
15 580
510 373
199 897
865 864
654 384
241 817
16 890
301 52
777 89
463 697
972 317
676 440
935 377
477 794
287 846
949 550
138 727
437 575
218 735
623 710
323 174
651 977
715 523
197 0
162 638
955 157
827 453
435 326
39 859
227 215
273 106
118 101
720 225
326 216
618 71
919 667
752 552
922 467
845 125
284 617
772 359
865 215
686 708
127 637
859 878
295 140
419 662
711 485
466 259
742 977
691 274
775 803
326 982
989 859
403 288
208 784
700 431
471 775
782 248
990 810
364 251
509 303
871 886
832 222
298 342
322 701
214 567
802 280
824 573
982 770
484 712
108 772
831 997
133 625
106 604
498 746
462 660
648 171
469 861
378 107
440 616
187 738
745 4
79 46
383 112
30 325
409 601
935 960
819 843
724 160
380 343
273 590
48 474
538 172
779 247
573 455
499 328
623 763
468 909
747 595
651 783
30 762
598 645
431 633
60 628
123 203
474 684
488 342
805 783
5 902
622 319
108 19
780 628
342 612
206 589
723 215
763 830
512 296
219 899
690 335
313 963
924 433
693 582
126 258
583 674
552 529
415 317
487 736
562 853
648 661
626 519
639 317
872 783
973 61
952 56
786 416
576 28
395 344
615 145
382 580
693 945
460 167
434 441
279 54
461 712
62 228
224 163
668 968
829 904
784 741
734 736
295 404
347 915
526 481
568 776
331 917
376 835
500 862
61 221
135 633
899 314
109 955
228 787
37 608
290 717
542 20
29 200
155 969
144 50
331 99
291 818
890 80
870 966
375 618
521 501
525 761
839 973
404 764
582 328
237 74
608 129
975 490
574 600
998 615
383 190
841 852
189 835
490 67
666 523
222 337
145 607
923 997
213 527
136 700
780 442
801 230
90 57
899 393
86 584
696 992
713 933
754 570
900 514
186 129
49 197
540 697
736 255
721 535
46 988
826 846
545 412
935 463
888 977
490 795
44 600
364 333
730 342
918 79
175 931
887 417
305 316
793 855
120 97
125 703
440 417
237 353
472 885
70 621
783 295
451 659
471 113
315 16
424 276
641 697
964 333
409 6
317 732
507 492
319 654
338 811
372 160
626 621
938 249
850 103
957 591
445 66
945 182
998 765
658 620
540 227
661 510
597 600
890 640
953 97
327 327
913 174
786 567
995 861
981 92
437 906
463 615
187 223
855 154
226 979
775 656
206 419
301 748
885 465
246 756
499 930
166 737
752 399
878 893
711 968
929 18
4 583
896 876
692 223
95 865
166 602
135 2
629 434
235 173
134 176
817 862
296 700
148 871
279 347
750 78
955 639
976 347
791 230
955 696
603 852
303 897
416 823
365 715
579 264
161 254
180 426
912 47
790 501
178 5
495 171
549 655
776 883
348 508
34 897
816 112
136 744
508 823
906 655
202 654
22 728
433 258
768 172
804 86
275 614
336 524
151 137
694 172
118 60
587 813
546 165
241 669
852 938
861 695
960 438
988 169
685 315
506 568
768 840
441 318
625 173
851 205
686 416
218 39
502 724
993 171
181 290
681 324
665 385
823 20
872 845
247 911
204 513
555 24
402 794
694 536
470 909
810 107
437 830
593 472
319 961
705 950
735 213
400 294
528 548
144 680
881 826
134 263
192 19
953 462
47 435
224 644
950 675
545 656
335 966
710 98
978 207
265 767
965 233
579 299
503 992
205 779
426 522
808 858
138 84
225 437
347 313
764 606
114 914
280 675
289 439
734 198
358 638
583 92
909 980
712 921
965 714
698 615
288 85
18 863
727 376
205 607
34 486
381 353
788 967
470 429
962 726
308 751
771 674
681 400
344 537
600 276
519 97
928 597
722 164
379 2
97 186
652 769
361 161
366 902
130 666
894 203
237 299
231 477
967 187
24 310
389 250
6 330
511 516
599 191
207 592
662 675
511 1
221 455
606 375
904 860
226 18
522 142
985 331
28 365
377 206
136 153
572 404
209 237
461 94
910 317
773 71
199 297
352 744
28 731
89 727
194 276
280 923
185 139
877 367
368 264
883 598
892 102
579 950
428 588
179 10
351 632
281 850
404 221
6 38
836 271
83 274
1 93
532 266
159 996
328 212
753 98
125 265
455 543
177 411
909 336
338 654
726 7
175 831
819 902
490 794
894 236
603 404
257 409
942 186
887 701
134 64
818 651
27 787
193 144
99 11
924 21
27 45
862 809
723 821
373 434
325 509
149 548
369 753
88 974
632 26
508 68
30 447
706 623
316 325
813 754
44 137
493 124
37 37
259 594
1 48
900 465
668 230
722 803
896 15
783 120
349 239
247 926
667 824
511 635
704 683
497 512
253 588
291 254
754 510
867 645
9 372
781 4
630 885
570 471
510 214
649 858
776 438
812 176
318 80
503 255
568 199
261 275
580 170
133 184
13 612
80 786
445 738
2 302
801 736
360 91
407 13
270 108
769 190
103 267
409 447
677 5
975 35
788 855
873 319
752 164
320 75
849 893
321 247
271 124
57 980
698 621
262 632
891 960
779 191
843 865
365 345
160 658
537 845
94 659
362 421
343 444
84 81
525 100
122 113
340 234
137 30
306 22
618 818
513 709
168 627
831 662
717 652
965 262
618 633
763 32
666 338
955 238
500 727
788 704
742 12
721 997
51 470
772 379
278 396
165 725
289 328
882 630
331 31
280 712
212 335
385 628
501 390
971 956
298 835
515 927
171 46
279 685
363 638
519 988
969 441
458 700
837 869
12 221
178 77
838 947
785 839
654 928
486 420
517 746
153 802
362 145
356 336
718 193
379 461
397 962
317 904
449 200
636 716
921 365
298 418
345 843
494 265
674 695
713 611
423 293
913 845
721 469
506 19
616 391
938 823
894 582
947 485
455 118
298 889
595 297
363 571
440 403
189 14
402 255
94 930
691 448
858 172
612 472
772 914
88 68
500 612
708 899
307 947
125 762
516 564
618 305
827 954
196 101
966 336
188 657
36 262
509 177
407 272
119 45
354 453
696 696
626 522
14 309
711 805
814 84
860 910
620 768
105 156
836 332
510 418
855 325
676 338
665 125
100 975
970 882
789 217
306 815
442 553
825 136
168 989
277 867
78 600
751 490
333 407
446 982
762 641
73 959
602 975
553 208
675 830
806 483
951 735
561 240
34 742
804 480
497 95
775 131
411 906
510 487
826 782
216 464
261 819
783 3
911 571
447 33
158 97
225 554
827 96
654 414
449 270
402 124
194 384
240 85
905 395
931 377
3 326
842 41
exit status 1 can you fix the verifier? ```go
package main
import (
"bufio"
"fmt"
"os"
"sort"
)
type SegTree struct {
n int
max []int
pos []int
lazy []int
}
func NewSegTree(n int) *SegTree {
if n == 0 {
return &SegTree{}
}
st := &SegTree{
n: n,
max: make([]int, 4*n),
pos: make([]int, 4*n),
lazy: make([]int, 4*n),
}
st.build(1, 0, n-1)
return st
}
func (st *SegTree) build(idx, l, r int) {
if l == r {
st.pos[idx] = l
return
}
mid := (l + r) >> 1
st.build(idx<<1, l, mid)
st.build(idx<<1|1, mid+1, r)
st.pos[idx] = st.pos[idx<<1]
}
func (st *SegTree) apply(idx, val int) {
st.max[idx] += val
st.lazy[idx] += val
}
func (st *SegTree) push(idx int) {
if st.lazy[idx] != 0 {
st.apply(idx<<1, st.lazy[idx])
st.apply(idx<<1|1, st.lazy[idx])
st.lazy[idx] = 0
}
}
func (st *SegTree) update(idx, l, r, ql, qr, val int) {
if ql > r || qr < l {
return
}
if ql <= l && r <= qr {
st.apply(idx, val)
return
}
st.push(idx)
mid := (l + r) >> 1
st.update(idx<<1, l, mid, ql, qr, val)
st.update(idx<<1|1, mid+1, r, ql, qr, val)
if st.max[idx<<1] >= st.max[idx<<1|1] {
st.max[idx] = st.max[idx<<1]
st.pos[idx] = st.pos[idx<<1]
} else {
st.max[idx] = st.max[idx<<1|1]
st.pos[idx] = st.pos[idx<<1|1]
}
}
func (st *SegTree) Update(l, r, val int) {
if l > r || st.n == 0 {
return
}
st.update(1, 0, st.n-1, l, r, val)
}
func (st *SegTree) query(idx, l, r, ql, qr int) (int, int) {
if ql > r || qr < l {
return -1, -1
}
if ql <= l && r <= qr {
return st.max[idx], st.pos[idx]
}
st.push(idx)
mid := (l + r) >> 1
leftMax, leftPos := st.query(idx<<1, l, mid, ql, qr)
rightMax, rightPos := st.query(idx<<1|1, mid+1, r, ql, qr)
if leftMax >= rightMax {
return leftMax, leftPos
}
return rightMax, rightPos
}
func (st *SegTree) Query(l, r int) (int, int) {
if l > r || st.n == 0 {
return -1, -1
}
return st.query(1, 0, st.n-1, l, r)
}
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n, sX, sY int
fmt.Fscan(reader, &n, &sX, &sY)
type event struct {
delta int
y1 int
y2 int
}
events := make(map[int][]event)
xs := make([]int, 0, 2*n+1)
ys := make([]int, 0, 2*n+1)
ys = append(ys, sY)
for i := 0; i < n; i++ {
var x, y int
fmt.Fscan(reader, &x, &y)
L := x
R := sX
if x > sX {
L = sX
R = x
}
D := y
U := sY
if y > sY {
D = sY
U = y
}
events[L] = append(events[L], event{1, D, U})
events[R+1] = append(events[R+1], event{-1, D, U})
xs = append(xs, L, R+1)
ys = append(ys, D, U)
}
xs = append(xs, sX)
sort.Ints(xs)
tmpX := xs[:0]
for _, v := range xs {
if len(tmpX) == 0 || tmpX[len(tmpX)-1] != v {
tmpX = append(tmpX, v)
}
}
xs = tmpX
sort.Ints(ys)
tmpY := ys[:0]
for _, v := range ys {
if len(tmpY) == 0 || tmpY[len(tmpY)-1] != v {
tmpY = append(tmpY, v)
}
}
ys = tmpY
st := NewSegTree(len(ys))
sYIdx := sort.Search(len(ys), func(i int) bool { return ys[i] >= sY })
maxCount := 0
bestX, bestY := -1, -1
for _, x := range xs {
if eList, ok := events[x]; ok {
for _, e := range eList {
l := sort.Search(len(ys), func(i int) bool { return ys[i] >= e.y1 })
r := sort.Search(len(ys), func(i int) bool { return ys[i] >= e.y2 })
st.Update(l, r, e.delta)
}
}
if x < 0 || x > 1000000000 {
continue
}
if x == sX {
if sYIdx > 0 {
cnt, pos := st.Query(0, sYIdx-1)
if cnt > maxCount {
maxCount = cnt
bestX = x
bestY = ys[pos]
}
}
if sYIdx < len(ys)-1 {
cnt, pos := st.Query(sYIdx+1, len(ys)-1)
if cnt > maxCount {
maxCount = cnt
bestX = x
bestY = ys[pos]
}
}
} else {
cnt, pos := st.Query(0, len(ys)-1)
if cnt > maxCount {
maxCount = cnt
bestX = x
bestY = ys[pos]
}
}
}
fmt.Fprintln(writer, maxCount)
fmt.Fprintln(writer, bestX, bestY)
}
```