QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#416488#8343. 玩游戏274551858530 9ms5508kbC++202.4kb2024-05-21 21:37:372024-05-21 21:37:38

Judging History

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

  • [2024-05-21 21:37:38]
  • 评测
  • 测评结果:30
  • 用时:9ms
  • 内存:5508kb
  • [2024-05-21 21:37:37]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#include<vector>
namespace Solve
{
    using namespace std;
    typedef long long ll;
    const int N=1000001;
    int n;
    bool h[N];
    void init(int _n)
    {
        n=_n;
    }
    int sum(ll x)
    {
        return (x%(n*2+1)+(n*2+1))%(n*2+1);
    }
    pair<int,int> encode(vector<int> a)
    {
        for(int i=0;i<=n*2;++i) h[i]=false;
        int s=0;
        for(auto i:a) s=sum(s+i);
        for(auto i:a) h[sum(i-s)]=true;
        auto mp=[&](int x,int y)
        {
            return make_pair(sum(x+s),sum(y+s));
        };
        for(pair<int,int> i:vector<pair<int,int>>{{0,1},{0,n*2},{n,2},{n,n*2-1},{4,n+1},{n*2-3,n+1}})
        {
            if(h[i.first]&&h[i.second]) return mp(i.first,i.second);
        }
        for(int i=1;i<=n-1;++i)
        {
            if(h[i]&&h[(n*2+1)-i])
            {
                return mp(i,(n*2+1)-i);
            }
        }
    }
    int decode(pair<int,int> a,pair<int,int> b)
    {
        auto solve=[&](int x1,int x2)
        {
            for(pair<int,int> i:vector<pair<int,int>>{{0,1},{0,n*2},{n,2},{n,n*2-1},{4,n+1},{n*2-3,n+1}})
            {
                if(sum(i.second-i.first)==sum(x2-x1))
                {
                    return sum((ll)((x1+x2)-(i.first+i.second))*(n+1));
                }
            }
            return sum((ll)(x1+x2)*(n+1));
        };
        int s1=solve(a.first,a.second),s2=solve(b.first,b.second);
        return sum(-s1-s2);
    }
}
void init(int n)
{
    return Solve::init(n);
}
std::pair<int, int> encode(std::vector<int> a)
{
    return Solve::encode(a);
}
int decode(std::pair<int, int> a, std::pair<int, int> b)
{
    return Solve::decode(a,b);
}

// int main()
// {
//     int T,n;
//     scanf("%d%d",&T,&n);
//     Solve::init(n);
//     while(T--)
//     {
//         std::vector<int> a,b;
//         for(int i=1;i<=n*2;++i)
//         {
//             int x;
//             scanf("%d",&x);
//             if(i<=n) a.push_back(x);
//             else b.push_back(x);
//         }
//         scanf("%*d");
//         auto xa=Solve::encode(a);
//         printf("%d %d\n",xa.first,xa.second);
//         auto xb=Solve::encode(b);
//         printf("%d %d\n",xb.first,xb.second);
//         int x=Solve::decode(xa,xb);
//         printf("%d\n",x);
//     }
//     return 0;
// }

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 9ms
memory: 5372kb

input:

6 16666 16807

output:

6 16666
2 11
3 6
3 1
8 11
0 9
8 11
2 3
6 0
1 8
6 4
0 5
4 3
1 10
11 7
7 12
9 10
2 3
7 8
3 6
7 10
3 12
5 6
2 7
5 10
5 6
0 7
9 5
0 3
10 11
3 8
12 10
0 9
9 8
1 0
3 12
6 5
10 2
6 9
2 11
0 12
5 1
3 2
4 5
7 12
11 3
9 8
4 7
3 2
11 7
6 4
7 12
6 5
7 6
10 2
8 9
5 1
1 2
7 12
6 11
12 2
5 1
6 7
2 7
9 5
5 4
1 12
3...

input:

6 16666
2 11
3 6
3 1
8 11
0 9
8 11
2 3
6 0
1 8
6 4
0 5
4 3
1 10
11 7
7 12
9 10
2 3
7 8
3 6
7 10
3 12
5 6
2 7
5 10
5 6
0 7
9 5
0 3
10 11
3 8
12 10
0 9
9 8
1 0
3 12
6 5
10 2
6 9
2 11
0 12
5 1
3 2
4 5
7 12
11 3
9 8
4 7
3 2
11 7
6 4
7 12
6 5
7 6
10 2
8 9
5 1
1 2
7 12
6 11
12 2
5 1
6 7
2 7
9 5
5 4
1 12
3...

output:

5
2
2
8
5
2
0
3
4
11
11
5
11
1
6
3
3
10
7
4
11
8
12
10
11
6
2
6
11
5
8
1
3
11
10
5
11
0
12
1
5
3
3
5
12
11
11
8
10
7
6
5
10
0
7
2
12
8
2
4
11
4
1
12
10
11
9
9
5
7
8
6
5
12
9
4
6
10
5
10
0
3
9
4
5
9
11
3
2
11
4
2
9
12
4
7
1
11
11
6
2
2
5
6
2
6
12
9
6
1
5
1
10
10
8
7
1
2
5
8
0
1
11
6
6
4
10
8
7
7
6
2
...

result:

wrong answer wrong answer: read 2 but expected 7 (test case 2)

Subtask #2:

score: 30
Accepted

Test #6:

score: 30
Accepted
time: 1ms
memory: 4672kb

input:

68876 1 470211272

output:

68876 1
105480 105479
96099 96098

input:

68876 1
105480 105479
96099 96098

output:

73927

result:

ok passed (1 test case)

Test #7:

score: 30
Accepted
time: 4ms
memory: 4372kb

input:

58538 1 101027544

output:

58538 1
44247 44241
69295 69296

input:

58538 1
44247 44241
69295 69296

output:

3538

result:

ok passed (1 test case)

Test #8:

score: 30
Accepted
time: 3ms
memory: 4412kb

input:

50603 1 1457850878

output:

50603 1
33820 84428
41099 91701

input:

50603 1
33820 84428
41099 91701

output:

76887

result:

ok passed (1 test case)

Test #9:

score: 30
Accepted
time: 5ms
memory: 4452kb

input:

33045 3 1458777923

output:

33045 3
52970 19921
57210 57209
36402 3361
270 271
56777 23728
60186 60184

input:

33045 3
52970 19921
57210 57209
36402 3361
270 271
56777 23728
60186 60184

output:

22006
29415
15224

result:

ok passed (3 test cases)

Test #10:

score: 30
Accepted
time: 2ms
memory: 4184kb

input:

20970 4 2007237709

output:

20970 4
4632 4633
32005 32004
6082 6083
2431 2421
16894 16888
11562 11552
11916 11917
13845 34814

input:

20970 4
4632 4633
32005 32004
6082 6083
2431 2421
16894 16888
11562 11552
11916 11917
13845 34814

output:

5304
33433
13493
37150

result:

ok passed (4 test cases)

Test #11:

score: 30
Accepted
time: 5ms
memory: 4536kb

input:

40786 2 823564440

output:

40786 2
8868 8869
48994 48995
55568 55560
29737 70526

input:

40786 2
8868 8869
48994 48995
55568 55560
29737 70526

output:

23711
37058

result:

ok passed (2 test cases)

Test #12:

score: 30
Accepted
time: 1ms
memory: 4492kb

input:

59198 1 1115438165

output:

59198 1
28252 87453
27613 86814

input:

59198 1
28252 87453
27613 86814

output:

62531

result:

ok passed (1 test case)

Test #13:

score: 30
Accepted
time: 3ms
memory: 5140kb

input:

92994 1 1784484492

output:

92994 1
149309 149305
185890 92894

input:

92994 1
149309 149305
185890 92894

output:

129775

result:

ok passed (1 test case)

Test #14:

score: 30
Accepted
time: 3ms
memory: 5508kb

input:

95914 1 74243042

output:

95914 1
127195 31285
12383 108300

input:

95914 1
127195 31285
12383 108300

output:

148161

result:

ok passed (1 test case)

Test #15:

score: 30
Accepted
time: 4ms
memory: 4348kb

input:

56585 1 114807987

output:

56585 1
40899 97483
104813 104814

input:

56585 1
40899 97483
104813 104814

output:

24044

result:

ok passed (1 test case)

Test #16:

score: 30
Accepted
time: 6ms
memory: 4684kb

input:

49131 2 1137522503

output:

49131 2
35126 35124
993 50127
58623 9488
65616 65614

input:

49131 2
35126 35124
993 50127
58623 9488
65616 65614

output:

13013
72292

result:

ok passed (2 test cases)

Test #17:

score: 30
Accepted
time: 4ms
memory: 4420kb

input:

58330 1 1441282327

output:

58330 1
115850 57516
104374 104375

input:

58330 1
115850 57516
104374 104375

output:

13102

result:

ok passed (1 test case)

Test #18:

score: 30
Accepted
time: 3ms
memory: 5508kb

input:

95899 1 16531729

output:

95899 1
90671 90670
19169 19168

input:

95899 1
90671 90670
19169 19168

output:

81959

result:

ok passed (1 test case)

Test #19:

score: 30
Accepted
time: 4ms
memory: 4376kb

input:

59202 1 823378840

output:

59202 1
64228 64229
110914 51708

input:

59202 1
64228 64229
110914 51708

output:

61672

result:

ok passed (1 test case)

Test #20:

score: 30
Accepted
time: 6ms
memory: 5140kb

input:

91350 1 143542612

output:

91350 1
175208 175209
88383 88384

input:

91350 1
175208 175209
88383 88384

output:

101811

result:

ok passed (1 test case)

Test #21:

score: 30
Accepted
time: 2ms
memory: 4448kb

input:

37397 2 896544303

output:

37397 2
32584 32583
6319 6301
56749 19354
70128 70127

input:

37397 2
32584 32583
6319 6301
56749 19354
70128 70127

output:

35901
60110

result:

ok passed (2 test cases)

Test #22:

score: 30
Accepted
time: 3ms
memory: 4316kb

input:

51165 1 1474833169

output:

51165 1
60146 60147
15037 15038

input:

51165 1
60146 60147
15037 15038

output:

27148

result:

ok passed (1 test case)

Test #23:

score: 30
Accepted
time: 4ms
memory: 4588kb

input:

61423 1 1264817709

output:

61423 1
78782 78752
107837 46410

input:

61423 1
78782 78752
107837 46410

output:

59094

result:

ok passed (1 test case)

Test #24:

score: 30
Accepted
time: 5ms
memory: 4040kb

input:

15177 6 1998097157

output:

15177 6
20910 5735
14875 30049
4431 4427
12748 27922
2294 17470
5869 21051
3237 18411
20377 20376
6537 6538
26687 11514
28228 28229
12091 12089

input:

15177 6
20910 5735
14875 30049
4431 4427
12748 27922
2294 17470
5869 21051
3237 18411
20377 20376
6537 6538
26687 11514
28228 28229
12091 12089

output:

9751
13182
7010
6745
27482
20392

result:

ok passed (6 test cases)

Test #25:

score: 30
Accepted
time: 1ms
memory: 5168kb

input:

91469 1 1817129560

output:

91469 1
103276 11805
169672 169673

input:

91469 1
103276 11805
169672 169673

output:

1460

result:

ok passed (1 test case)

Test #26:

score: 30
Accepted
time: 5ms
memory: 4048kb

input:

7001 14 1131570933

output:

7001 14
13841 6838
8168 1165
13441 6436
11680 11679
11698 4695
6337 6338
2564 9562
11643 4646
6162 13166
7424 7422
12659 5656
313 314
2320 2318
489 7489
547 537
13652 13653
3881 10881
2285 2286
1714 1712
2771 2770
7705 706
5826 12826
11367 4368
5592 5591
11168 11169
6488 13492
8813 1814
6321 6320

input:

7001 14
13841 6838
8168 1165
13441 6436
11680 11679
11698 4695
6337 6338
2564 9562
11643 4646
6162 13166
7424 7422
12659 5656
313 314
2320 2318
489 7489
547 537
13652 13653
3881 10881
2285 2286
1714 1712
2771 2770
7705 706
5826 12826
11367 4368
5592 5591
11168 11169
6488 13492
8813 1814
6321 6320

output:

5996
2889
2969
13799
7419
8032
4193
13812
835
9519
471
4045
3348
5870

result:

ok passed (14 test cases)

Test #27:

score: 30
Accepted
time: 5ms
memory: 4048kb

input:

13730 7 197493099

output:

13730 7
16985 16986
15854 2126
8643 8644
2572 2573
8230 21963
2054 2052
8970 22703
14517 14501
18969 18970
15312 1584
23019 9285
1667 1663
14084 14085
20575 6843

input:

13730 7
16985 16986
15854 2126
8643 8644
2572 2573
8230 21963
2054 2052
8970 22703
14517 14501
18969 18970
15312 1584
23019 9285
1667 1663
14084 14085
20575 6843

output:

8352
16246
3447
17712
6910
2781
6532

result:

ok passed (7 test cases)

Test #28:

score: 30
Accepted
time: 3ms
memory: 3844kb

input:

5908 16 1404280278

output:

5908 16
11351 11347
6940 1030
8192 8190
34 32
6335 6336
9311 9312
7163 7164
1003 1001
16 12
1175 1163
7785 1879
6344 6342
1371 1372
7575 1671
84 85
795 794
453 6360
4392 4388
2366 2367
5696 11607
8090 8076
2632 8543
964 6871
4730 4731
11683 5779
11141 11133
5881 11792
7855 1951
6684 6685
4754 4755
4...

input:

5908 16
11351 11347
6940 1030
8192 8190
34 32
6335 6336
9311 9312
7163 7164
1003 1001
16 12
1175 1163
7785 1879
6344 6342
1371 1372
7575 1671
84 85
795 794
453 6360
4392 4388
2366 2367
5696 11607
8090 8076
2632 8543
964 6871
4730 4731
11683 5779
11141 11133
5881 11792
7855 1951
6684 6685
4754 4755
4...

output:

11253
3593
7988
3652
10634
3597
2867
10938
1065
9663
7010
214
810
3985
379
1438

result:

ok passed (16 test cases)

Test #29:

score: 30
Accepted
time: 3ms
memory: 4452kb

input:

53685 1 893351816

output:

53685 1
76992 23311
54628 947

input:

53685 1
76992 23311
54628 947

output:

83114

result:

ok passed (1 test case)

Test #30:

score: 30
Accepted
time: 5ms
memory: 4508kb

input:

29258 3 1505795335

output:

29258 3
23310 23302
54070 54071
29516 260
15931 15930
30973 30957
57117 27861

input:

29258 3
23310 23302
54070 54071
29516 260
15931 15930
30973 30957
57117 27861

output:

39658
42328
58210

result:

ok passed (3 test cases)

Subtask #3:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 8ms
memory: 4492kb

input:

18 5555 1954899097

output:

18 5555
20 19
34 14
14 4
31 32
27 11
32 16
15 9
25 24
16 14
35 15
15 30
36 20
34 35
1 22
24 23
15 36
23 1
22 4
35 36
31 30
14 35
26 25
6 23
2 17
14 15
22 23
18 2
4 25
12 29
32 33
13 36
10 8
34 33
4 21
0 21
7 22
17 3
20 21
22 4
9 26
36 35
16 0
18 16
0 21
33 32
35 31
13 14
0 21
27 21
32 30
35 19
3 26
...

input:

18 5555
20 19
34 14
14 4
31 32
27 11
32 16
15 9
25 24
16 14
35 15
15 30
36 20
34 35
1 22
24 23
15 36
23 1
22 4
35 36
31 30
14 35
26 25
6 23
2 17
14 15
22 23
18 2
4 25
12 29
32 33
13 36
10 8
34 33
4 21
0 21
7 22
17 3
20 21
22 4
9 26
36 35
16 0
18 16
0 21
33 32
35 31
13 14
0 21
27 21
32 30
35 19
3 26
...

output:

1
34
14
0
5
8
20
16
5
8
15
14
1
14
11
11
17
15
33
33
3
1
8
5
19
13
18
29
15
7
11
9
9
15
19
5
7
2
34
7
6
19
6
3
10
7
1
19
32
30
25
24
3
13
7
17
9
36
15
3
5
16
16
17
33
0
28
36
15
21
11
15
30
19
6
0
0
1
3
0
10
34
13
10
33
2
2
4
2
12
35
14
33
29
36
35
11
3
17
21
12
10
29
7
2
30
33
24
25
19
18
36
31
28
...

result:

wrong answer wrong answer: read 3 but expected 30 (test case 21)