编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#82066 #1152. 连连看 Wrong Answer 0 936 ms 5512 K C++ 11 / 1.7 K y 2023-03-10 20:44:30
显示原始代码
#include <algorithm>
#include <cstdio>
#define N 100009
#define RI register int
#define Abs(x) (x > 0 ? x : -x)
using namespace std;

bool ind[N];
int n, st[4], f[2][N], sf, ans;

struct DT {
    int x, y, i;
} a[4][N];

inline int read();
inline int get(DT x, DT y) { return Abs(x.x - y.x) + Abs(x.y - y.y); }
bool cmp0(DT x, DT y) { return x.x < y.x; }
bool cmp1(DT x, DT y) { return x.x > y.x; }
bool cmp2(DT x, DT y) { return x.y < y.y; }
bool cmp3(DT x, DT y) { return x.y > y.y; }

int main() {
    n = read();
    st[0] = st[1] = st[2] = st[3] = 1;
    for (RI i = 1, xi, yi; i <= n; ++i) {
        xi = read(), yi = read();
        for (RI j = 0; j < 4; ++j) a[j][i].i = i, a[j][i].x = xi + yi, a[j][i].y = xi - yi;
    }
    sort(a[0] + 1, a[0] + 1 + n, cmp0);
    sort(a[1] + 1, a[1] + 1 + n, cmp1);
    sort(a[2] + 1, a[2] + 1 + n, cmp2);
    sort(a[3] + 1, a[3] + 1 + n, cmp3);
    for (RI i = 2; i <= n; i += 2) {
        for (RI j = 0; j < 4; ++j)
            while (st[j] && ind[a[j][st[j]].i]) ++st[j];
        int now1 = get(a[0][st[0]], a[1][st[1]]);
        int now2 = get(a[2][st[2]], a[3][st[3]]);
        if (now1 > now2) {
            ans += now1;
            ++sf;
            ind[a[0][st[0]].i] = true;
            ind[a[1][st[1]].i] = true;
            f[0][sf] = a[0][st[0]].i;
            f[1][sf] = a[1][st[1]].i;
        } else {
            ans += now2;
            ++sf;
            ind[a[2][st[2]].i] = true;
            ind[a[3][st[3]].i] = true;
            f[0][sf] = a[2][st[2]].i;
            f[1][sf] = a[3][st[3]].i;
        }
    }
    printf("%d\n", sf);
    for (RI i = 1; i <= sf; ++i) printf("%d %d\n", f[0][i], f[1][i]);
    return 0;
}

inline int read() {
    int x = 0;
    char c = getchar();
    while (c > '9' || c < '0') c = getchar();
    while (c >= '0' && c <= '9') {
        x *= 10;
        x += c - '0';
        c = getchar();
    }
    return x;
}
子任务 #1
Wrong Answer
得分:0
测试点 #1
Wrong Answer
得分:0
用时:55 ms
内存:5432 KiB

输入文件(input1.in

99994
39904 35083
46820 36679
18613 3814
6474 19631
37764 36525
18319 33414
45300 26489
21133 11529

<1155515 bytes omitted>

答案文件(input1.out

1665399942

用户输出

49997
38261 74276
41431 93716
24609 4144
83202 53266
78107 3361
64397 13482
88312 44989
37939 43689
2406 36363
29540 7597
51843 
<588736 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #2
Wrong Answer
得分:0
用时:55 ms
内存:5444 KiB

输入文件(input2.in

99966
29572 24605
33552 8402
18093 9640
547 31444
251 3309
43619 22874
32618 14747
3018 19766
37882 
<1155228 bytes omitted>

答案文件(input2.out

1664919648

用户输出

49983
82482 4885
27429 13112
33629 54428
55130 56197
77673 77174
88008 29981
93408 78594
39168 66426
64602 31374
21470 1892
9532
<588568 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #3
Wrong Answer
得分:0
用时:50 ms
内存:5436 KiB

输入文件(input3.in

99959
24963 15592
20533 22230
22960 10397
32438 32270
16368 45627
25843 147
28835 6570
37998 16798
1
<1155287 bytes omitted>

答案文件(input3.out

1661963157

用户输出

49979
88711 14563
4285 63149
87245 61621
20142 24200
16181 72433
73562 16847
94700 99424
69641 14058
48843 5632
1545 56853
27397
<588520 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #4
Wrong Answer
得分:0
用时:52 ms
内存:5476 KiB

输入文件(input4.in

99950
2417 45567
19300 44813
23263 44027
33863 2702
39461 4555
42612 32590
15374 27421
31106 10493
4
<1155004 bytes omitted>

答案文件(input4.out

1662916373

用户输出

49975
77289 80800
81788 27199
83305 17022
60794 62179
92164 31856
63627 82662
40780 19418
91744 36598
71223 66290
71742 42676
79
<588472 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #5
Wrong Answer
得分:0
用时:58 ms
内存:5476 KiB

输入文件(input5.in

99972
45280 44508
29577 24171
8151 8714
7100 44734
49861 28412
31199 14196
17156 34102
32122 48695
4
<1155310 bytes omitted>

答案文件(input5.out

1664148272

用户输出

49986
67518 50230
73864 30872
28915 29726
82257 57878
23820 18450
1000 15263
81917 92557
32742 83600
5464 11585
50243 43572
8289
<588604 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #6
Wrong Answer
得分:0
用时:51 ms
内存:5476 KiB

输入文件(input7.in

99994
22203 12731
48860 13276
9330 45678
45445 29249
15122 11965
11386 19038
21223 30977
15157 31632
<1155538 bytes omitted>

答案文件(input7.out

1665321412

用户输出

49997
55359 25758
95625 64228
13969 327
94007 23784
45575 91410
5437 87633
12808 77238
33380 21638
111 14981
56731 3679
35719 61
<588736 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #7
Wrong Answer
得分:0
用时:30 ms
内存:5480 KiB

输入文件(input8.in

99994
8 4
10 6
4 4
6 9
7 5
9 5
10 8
8 3
2 7
2 10
10 2
2 10
9 9
6 7
5 4
8 4
3 10
10 8
7 5
8 5
10 8
8 
<419780 bytes omitted>

答案文件(input8.out

330146

用户输出

49997
98148 22365
41750 81222
35935 32000
54419 96185
18013 81294
26674 65395
44290 96209
11335 22375
39085 91801
51186 14384
89
<588736 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #8
Wrong Answer
得分:0
用时:32 ms
内存:5448 KiB

输入文件(input9.in

99969
4 8
8 6
2 6
9 10
4 10
10 4
1 5
9 9
3 9
9 2
7 3
1 10
10 9
9 3
8 4
9 6
10 5
3 7
9 4
6 6
3 10
10 
<419576 bytes omitted>

答案文件(input9.out

329492

用户输出

49984
12142 84745
54610 83179
22801 6801
15191 4725
22813 24257
5583 854
4954 84744
79891 65525
36762 73696
27861 4716
91877 577
<588581 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #9
Wrong Answer
得分:0
用时:38 ms
内存:5424 KiB

输入文件(input10.in

99987
5 10
6 10
7 6
10 4
2 10
10 5
10 5
2 8
9 4
1 9
4 9
8 4
9 7
5 7
6 4
7 8
5 6
1 5
5 7
5 6
4 8
9 3

<419631 bytes omitted>

答案文件(input10.out

329440

用户输出

49993
42864 49018
32417 48406
42997 12783
23914 5116
92043 48664
63462 48691
98170 48896
42975 48937
98601 79097
9534 18012
3103
<588688 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #10
Wrong Answer
得分:0
用时:38 ms
内存:5488 KiB

输入文件(input11.in

99987
8 8
6 10
9 8
6 7
7 4
3 8
1 7
5 8
5 7
8 8
9 3
1 5
3 10
10 8
1 5
3 7
10 4
9 2
4 1
7 6
2 1
1 10
4
<419934 bytes omitted>

答案文件(input11.out

330047

用户输出

49993
90350 27643
12301 51217
26029 27779
61284 27769
32851 96737
26053 51189
62709 93150
90372 13082
90354 71830
50107 84739
95
<588688 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #11
Wrong Answer
得分:0
用时:28 ms
内存:5464 KiB

输入文件(input12.in

99991
1 9
6 6
8 9
8 9
10 10
3 7
8 10
4 5
3 6
6 10
3 8
7 7
1 6
7 1
9 2
3 1
6 7
7 10
5 4
7 3
8 9
3 3
1
<419968 bytes omitted>

答案文件(input12.out

330232

用户输出

49995
3113 25276
47455 99290
98772 2193
1728 36388
38717 74931
26623 93628
31406 31343
10859 25281
92502 54051
31401 58133
31399
<588712 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #12
Wrong Answer
得分:0
用时:31 ms
内存:5436 KiB

输入文件(input13.in

99981
2 5
7 10
9 9
9 8
3 10
10 1
5 4
9 10
7 7
9 2
3 3
5 8
10 9
6 10
3 4
1 6
2 1
8 7
9 1
2 9
1 1
3 10
<419894 bytes omitted>

答案文件(input13.out

329860

用户输出

49990
14060 55473
34807 88755
82245 55463
71904 24686
66762 55468
40604 77297
92126 82621
56224 25550
15813 60221
56261 58930
95
<588652 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #13
Wrong Answer
得分:0
用时:29 ms
内存:5408 KiB

输入文件(input14.in

99970
2 6
8 5
4 5
4 7
6 9
1 8
2 7
6 6
3 8
1 3
5 5
10 8
10 2
3 9
4 4
2 6
1 9
9 8
7 8
1 7
5 6
6 5
10 3
<419547 bytes omitted>

答案文件(input14.out

329442

用户输出

49985
58837 77941
43363 34905
17064 7836
23772 7093
93852 45490
64114 45550
7593 56560
23821 97860
7562 2471
58889 56655
7541 53
<588592 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #14
Wrong Answer
得分:0
用时:55 ms
内存:5432 KiB

输入文件(input15.in

99951
43016666 705054189
23890816 191954409
48367680 178083192
65698935 509772667
809449080 63876393
<1972731 bytes omitted>

答案文件(input15.out

33839316800310

用户输出

49975
2134 90977
49874 18708
58697 36792
6329 11237
31672 16442
93579 89761
93669 15468
34546 14263
99950 58445
39534 62022
6228
<588472 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #15
Wrong Answer
得分:0
用时:63 ms
内存:5432 KiB

输入文件(input16.in

99950
390196982 16217026
756299460 557589375
845307426 215064985
403301484 72900781
989173256 503715
<1973044 bytes omitted>

答案文件(input16.out

33893190316304

用户输出

49975
2088 90857
80364 5318
63086 56411
23118 59999
35079 60164
15038 17222
33479 88928
10981 59578
84332 60702
52073 41561
3974
<588472 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #16
Wrong Answer
得分:0
用时:52 ms
内存:5512 KiB

输入文件(input17.in

99966
309713742 103345138
912956589 605640153
759597371 959523157
958180894 12282372
124979541 33724
<1973228 bytes omitted>

答案文件(input17.out

33869086670134

用户输出

49983
82562 40585
91668 60618
17269 93834
26180 93291
30424 18415
8704 20207
29486 27152
31305 91031
52894 8771
91627 34438
2615
<588568 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #17
Wrong Answer
得分:0
用时:59 ms
内存:5432 KiB

输入文件(input18.in

99989
662308788 188157881
945161135 936031796
224331765 646572957
176241418 73020933
141324820 14925
<1973587 bytes omitted>

答案文件(input18.out

33895043667584

用户输出

49994
86562 50942
43778 63772
59447 8673
25575 69208
58658 85185
31061 2128
53726 77912
75553 25863
37678 422
58693 84740
40092 
<588702 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #18
Wrong Answer
得分:0
用时:54 ms
内存:5476 KiB

输入文件(input19.in

99973
154453232 656240272
715155228 848233937
852480696 275617197
561544202 123073069
472873249 7570
<1973611 bytes omitted>

答案文件(input19.out

33855972714822

用户输出

49986
34752 86753
60647 72816
83352 81094
72770 26919
64842 89301
99714 77497
91470 70878
42583 31918
46269 59475
55242 77081
28
<588605 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #19
Wrong Answer
得分:0
用时:53 ms
内存:5440 KiB

输入文件(input20.in

99963
330145838 658516321
110794903 347274671
457221490 32851628
825966653 737106317
215914215 91143
<1973595 bytes omitted>

答案文件(input20.out

33750931421773

用户输出

49981
18885 56057
77633 77030
81793 27180
96216 7976
98979 48260
22225 50236
54830 56222
42073 40291
27305 45024
18287 87439
712
<588544 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0
测试点 #20
Wrong Answer
得分:0
用时:53 ms
内存:5488 KiB

输入文件(input21.in

99955
645861926 798882887
204604371 64809073
832321434 183260368
540647278 28314156
852540009 437805
<1973031 bytes omitted>

答案文件(input21.out

33814666330789

用户输出

49977
56137 26765
17180 20297
92217 75268
8561 16021
26422 85820
91298 65435
9977 9944
82471 76248
54309 57979
3834 45878
42262 
<588496 bytes omitted>

Special Judge 信息

Something is wrong...

系统信息

Exited with return code 0