CSES - Datatähti 2025 loppu - Results
Submission details
Task:Leikkijät
Sender:adex720
Submission time:2025-01-18 16:29:00 +0200
Language:C++ (C++20)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
#60
Test results
testverdicttimegroup
#10.01 s1, 2, 5, 6details
#20.00 s1, 2, 3, 5, 6details
#30.01 s1, 2, 5, 6details
#40.00 s1, 2, 4, 5, 6details
#50.00 s2, 5, 6details
#60.01 s2, 3, 5, 6details
#70.01 s2, 5, 6details
#80.00 s2, 4, 5, 6details
#90.00 s5, 6details
#100.01 s6details
#110.01 s1, 2, 5, 6details
#120.01 s6details
#130.00 s3, 5, 6details
#140.00 s3, 5, 6details
#150.00 s4, 5, 6details
#160.01 s5, 6details
#170.00 s6details
#180.01 s4, 5, 6details
#190.00 s5, 6details
#200.01 s6details
#210.00 s6details
#220.01 s5, 6details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:37:17: warning: unused variable 'debug' [-Wunused-variable]
   37 |             int debug = 5;
      |                 ^~~~~

Code

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

using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t, a, b;
    cin >> t;

    int n = 500;
    int seuraavat[n + 1][n + 1];
    seuraavat[1][1] = 1;

    seuraavat[2][1] = 1;
    seuraavat[2][2] = 1;

    seuraavat[3][1] = 3;
    seuraavat[3][2] = 1;
    seuraavat[3][3] = 3;

    for (int i = 4; i <= n; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            seuraavat[i][j] = 0;
        }
    }

    for (int i = 4; i <= n; i++)
    {
        if (i == 21)
        {
            int debug = 5;
        }
        int edellinen = 2;
        int lisays = 2;
        int nykyinen = 4;
        for (int j = 2; j <= i; j++)
        {
            if (j == i && seuraavat[i][nykyinen])
            {
                int puuttuva;
                for (puuttuva = 1; seuraavat[i][puuttuva] || puuttuva == nykyinen; puuttuva++)
                    ;

                seuraavat[i][edellinen] = puuttuva;
                seuraavat[i][puuttuva] = puuttuva;
                break;
            }

            seuraavat[i][edellinen] = nykyinen;
            edellinen = nykyinen;
            nykyinen += lisays;
            if (nykyinen > i)
            {
                nykyinen = (nykyinen - i) * 2 - 1;
                if (nykyinen > i)
                    nykyinen -= i;
                lisays <<= 1;
            }
        }

        if (nykyinen > i)
            nykyinen -= i;
        seuraavat[i][nykyinen] = nykyinen;
    }

    for (int i = 0; i < t; i++)
    {
        cin >> a >> b;
        if ((a & 1) == 0)
        {
            if (b == 1)
            {
                cout << (a == 2 ? 2 : a + 1) << "\n";
                continue;
            }
            if (b == 3)
            {
                if (a == 2)
                {
                    cout << -1 << "\n";
                    continue;
                }

                cout << a << "\n";
                continue;
            }

            if (a + 2 == b)
            {
                cout << b << "\n";
                continue;
            }

            cout << -1 << "\n";
            continue;
        }

        int joo = 1;
        for (int i = max(a, b); i <= n; i++)
        {
            if (seuraavat[i][a] == b)
            {
                cout << i << "\n";
                joo = 0;
                break;
            }
        }

        if (joo)
        {
            cout << "-1\n";
        }
    }
}

Test details

Test 1

Group: 1, 2, 5, 6

Verdict:

input
1000
42 100
73 94
1 13
31 100
...

correct output
-1
-1
-1
-1
-1
...

user output
(empty)

Test 2

Group: 1, 2, 3, 5, 6

Verdict:

input
1000
54 3
42 44
30 1
52 3
...

correct output
54
44
31
52
15
...

user output
(empty)

Test 3

Group: 1, 2, 5, 6

Verdict:

input
1000
27 25
81 65
45 43
87 23
...

correct output
-1
-1
-1
139
-1
...

user output
(empty)

Test 4

Group: 1, 2, 4, 5, 6

Verdict:

input
1000
55 63
39 71
95 96
61 69
...

correct output
65
75
-1
72
98
...

user output
(empty)

Test 5

Group: 2, 5, 6

Verdict:

input
1000
222 56
871 832
207 364
919 980
...

correct output
-1
-1
-1
-1
-1
...

user output
(empty)

Test 6

Group: 2, 3, 5, 6

Verdict:

input
1000
892 3
332 334
820 822
42 1
...

correct output
892
334
822
43
108
...

user output
(empty)

Test 7

Group: 2, 5, 6

Verdict:

input
1000
77 93
319 575
509 381
675 707
...

correct output
98
607
574
713
919
...

user output
(empty)

Test 8

Group: 2, 4, 5, 6

Verdict:

input
1000
969 985
233 489
403 659
427 555
...

correct output
992
500
777
565
261
...

user output
(empty)

Test 9

Group: 5, 6

Verdict:

input
1000
10375 364462
501875 499131
495774 7544
133830 316225
...

correct output
-1
-1
-1
-1
-1
...

user output
(empty)

Test 10

Group: 6

Verdict:

input
100000
771321 298762
20752 494590
633649 443015
748804 831912
...

correct output
-1
-1
-1
-1
-1
...

user output
(empty)

Test 11

Group: 1, 2, 5, 6

Verdict:

input
900
1 1
1 2
1 3
1 4
...

correct output
-1
-1
3
-1
5
...

user output
(empty)

Test 12

Group: 6

Verdict:

input
90000
1 1
1 2
1 3
1 4
...

correct output
-1
-1
3
-1
5
...

user output
(empty)

Test 13

Group: 3, 5, 6

Verdict:

input
1000
237542 859435
965750 179154
972602 758585
453450 751662
...

correct output
-1
-1
-1
-1
-1
...

user output
(empty)

Test 14

Group: 3, 5, 6

Verdict:

input
1000
773164 1
870426 1
309736 309738
957602 957604
...

correct output
773165
870427
309738
957604
513118
...

user output
(empty)

Test 15

Group: 4, 5, 6

Verdict:

input
1000
178896 591355
54364 110987
361539 818612
275401 926643
...

correct output
-1
-1
-1
-1
-1
...

user output
(empty)

Test 16

Group: 5, 6

Verdict:

input
1000
704481 704465
696919 688727
941011 949203
171023 171025
...

correct output
-1
-1
951785
-1
-1
...

user output
(empty)

Test 17

Group: 6

Verdict:

input
100000
67901 133437
637521 637537
742567 742569
864043 864044
...

correct output
148638
637540
-1
-1
652457
...

user output
(empty)

Test 18

Group: 4, 5, 6

Verdict:

input
1000
650375 650377
181841 443985
750137 750138
256969 322505
...

correct output
-1
484136
-1
341476
850152
...

user output
(empty)

Test 19

Group: 5, 6

Verdict:

input
1000
1 3
1 5
1 9
1 17
...

correct output
3
5
10
20
40
...

user output
(empty)

Test 20

Group: 6

Verdict:

input
100000
1 3
1 5
1 9
1 17
...

correct output
3
5
10
20
40
...

user output
(empty)

Test 21

Group: 6

Verdict:

input
100000
999999 1
999999 3
999999 5
999999 7
...

correct output
1000002
1000005
1000000
1000011
1000001
...

user output
(empty)

Test 22

Group: 5, 6

Verdict:

input
1000
999999 1
999999 3
999999 5
999999 7
...

correct output
1000002
1000005
1000000
1000011
1000001
...

user output
(empty)