CSES - HIIT Open 2024 - Results
Submission details
Task:Gerbil's run
Sender:Sold days
Submission time:2024-11-16 16:57:33 +0200
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#110.00 sdetails
#120.00 sdetails
#130.00 sdetails
#140.01 sdetails
#15ACCEPTED0.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#180.00 sdetails
#190.00 sdetails
#200.00 sdetails
#21ACCEPTED0.00 sdetails
#220.00 sdetails
#23ACCEPTED0.00 sdetails
#24ACCEPTED0.00 sdetails
#25ACCEPTED0.00 sdetails
#26ACCEPTED0.00 sdetails
#27ACCEPTED0.00 sdetails
#280.00 sdetails
#290.00 sdetails
#300.00 sdetails
#31ACCEPTED0.00 sdetails
#32ACCEPTED0.00 sdetails
#330.00 sdetails
#340.00 sdetails
#350.00 sdetails
#36ACCEPTED0.00 sdetails
#37ACCEPTED0.00 sdetails
#38ACCEPTED0.00 sdetails
#390.00 sdetails
#40ACCEPTED0.01 sdetails
#41ACCEPTED0.00 sdetails
#42ACCEPTED0.00 sdetails
#43ACCEPTED0.00 sdetails
#44ACCEPTED0.00 sdetails
#450.01 sdetails

Code

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

using ld = long double;
using ll = long long;

const ld PI = M_PI;

const ll mult = 30000;
const int range = 5000;

ld r = 0;
ld totalLen = 0;

ld eps = 1e-16;

bool check(ld alpha, ld extra)
{
    if ((alpha < 0) || (alpha + extra + eps >= 1))
        return false;
    ll x = (ll)floorl(totalLen / (1 + alpha));
    if (x % 2 == 1) {
        return false;
    }
    if (alpha + totalLen - (x * (1 + alpha)) + eps >= 1) {
        return false;
    }
    return true;
}

pair<pair<ll, ll>, pair<ll, ll>> getAlpha()
{
    if (check(0, 0))
    {
        return {{0, 2}, {0, 2}};
    }

    vector<pair<ll, ll>> extras = {{0, 2}, {1, 4}, {1, 2}, {3, 4}};

    for (auto extra : extras) {
        totalLen = (PI * r * 2.0);
        totalLen -= (ld)extra.first / extra.second;

        ld x = floor(totalLen);
        ld b = totalLen - x;
        
        ld alphaStart = (totalLen) / (totalLen + b + 1) - 1;
        ll enumer = (ll)(alphaStart * mult);
        for (ll alphaEnum = enumer - range; alphaEnum < enumer + range; ++alphaEnum)
        {
            if (check((ld)alphaEnum / mult, (ld)extra.first / extra.second))
            {
                return {{alphaEnum, mult}, extra};
            }
        }

        enumer = 0;
        for (ll alphaEnum = enumer - range; alphaEnum < enumer + range; ++alphaEnum)
        {
            if (check((ld)alphaEnum / mult, (ld)extra.first / extra.second))
            {
                return {{alphaEnum, mult}, extra};
            }
        }
    }
    

    assert(false);
    return {{0, 0}, {0, 0}};
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    // for (int r1 = 1; r1 < 1001; ++r1) {
    //     cout << r1 << "\n";
    //     r = r1;
    //     totalLen = (2 * PI * r);

    //     auto alpha = getAlpha();
    // }

    cin >> r;
    totalLen = (PI * r * 2.0);

    auto [alpha, extra] = getAlpha();
    pair<ll, ll> len = {alpha.first + alpha.second, alpha.second};
    pair<ll, ll> prev = len;
    pair<ll, ll> pos = {len.first * 2 + extra.first * (len.second / extra.second), len.second};
    // cout << extra.first * (pos.second / extra.second)<< '\n';
    // cout << len.first * 2 + extra.first * (pos.second / extra.second)<< '\n';
    // cout << pos.second<< '\n';
    // cout << (ld)pos.first / pos.second<< '\n';
    totalLen = (PI * r * 2.0);
    while ((ld)pos.first < totalLen * pos.second)
    {
        cout << prev.first << '/' << prev.second << ' ' << pos.first << '/' << pos.second << '\n';

        pos.first += len.first;
        prev = pos;
        pos.first += len.first;
    }

    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
1

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2

Test 2

Verdict: ACCEPTED

input
2

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 3

Verdict: ACCEPTED

input
3

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 4

Verdict:

input
4

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30174/30000 60348/30000
90522/30000 120696/30000
150870/30000 181044/30000
211218/30000 241392/30000
271566/30000 301740/30000
...

Test 5

Verdict:

input
5

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30431/30000 60862/30000
91293/30000 121724/30000
152155/30000 182586/30000
213017/30000 243448/30000
273879/30000 304310/30000
...

Test 6

Verdict:

input
6

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30600/30000 61200/30000
91800/30000 122400/30000
153000/30000 183600/30000
214200/30000 244800/30000
275400/30000 306000/30000
...

Test 7

Verdict:

input
7

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30719/30000 61438/30000
92157/30000 122876/30000
153595/30000 184314/30000
215033/30000 245752/30000
276471/30000 307190/30000
...

Test 8

Verdict: ACCEPTED

input
8

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 9

Verdict: ACCEPTED

input
9

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 10

Verdict: ACCEPTED

input
10

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 11

Verdict:

input
11

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30052/30000 60104/30000
90156/30000 120208/30000
150260/30000 180312/30000
210364/30000 240416/30000
270468/30000 300520/30000
...

Test 12

Verdict:

input
12

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30164/30000 60328/30000
90492/30000 120656/30000
150820/30000 180984/30000
211148/30000 241312/30000
271476/30000 301640/30000
...

Test 13

Verdict:

input
13

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30259/30000 60518/30000
90777/30000 121036/30000
151295/30000 181554/30000
211813/30000 242072/30000
272331/30000 302590/30000
...

Test 14

Verdict:

input
14

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30341/30000 60682/30000
91023/30000 121364/30000
151705/30000 182046/30000
212387/30000 242728/30000
273069/30000 303410/30000
...

Test 15

Verdict: ACCEPTED

input
15

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 16

Verdict: ACCEPTED

input
16

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 17

Verdict: ACCEPTED

input
17

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 18

Verdict:

input
18

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30027/30000 60054/30000
90081/30000 120108/30000
150135/30000 180162/30000
210189/30000 240216/30000
270243/30000 300270/30000
...

Test 19

Verdict:

input
19

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30098/30000 60196/30000
90294/30000 120392/30000
150490/30000 180588/30000
210686/30000 240784/30000
270882/30000 300980/30000
...

Test 20

Verdict:

input
20

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30162/30000 60324/30000
90486/30000 120648/30000
150810/30000 180972/30000
211134/30000 241296/30000
271458/30000 301620/30000
...

Test 21

Verdict: ACCEPTED

input
50

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 22

Verdict:

input
98

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30037/30000 60074/30000
90111/30000 120148/30000
150185/30000 180222/30000
210259/30000 240296/30000
270333/30000 300370/30000
...

Test 23

Verdict: ACCEPTED

input
99

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 24

Verdict: ACCEPTED

input
100

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 25

Verdict: ACCEPTED

input
101

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 26

Verdict: ACCEPTED

input
102

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 27

Verdict: ACCEPTED

input
158

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 28

Verdict:

input
159

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30001/30000 60002/30000
90003/30000 120004/30000
150005/30000 180006/30000
210007/30000 240008/30000
270009/30000 300010/30000
...

Test 29

Verdict:

input
160

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30010/30000 60020/30000
90030/30000 120040/30000
150050/30000 180060/30000
210070/30000 240080/30000
270090/30000 300100/30000
...

Test 30

Verdict:

input
161

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30018/30000 60036/30000
90054/30000 120072/30000
150090/30000 180108/30000
210126/30000 240144/30000
270162/30000 300180/30000
...

Test 31

Verdict: ACCEPTED

input
313

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 32

Verdict: ACCEPTED

input
314

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 33

Verdict:

input
315

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30004/30000 60008/30000
90012/30000 120016/30000
150020/30000 180024/30000
210028/30000 240032/30000
270036/30000 300040/30000
...

Test 34

Verdict:

input
316

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30008/30000 60016/30000
90024/30000 120032/30000
150040/30000 180048/30000
210056/30000 240064/30000
270072/30000 300080/30000
...

Test 35

Verdict:

input
317

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30012/30000 60024/30000
90036/30000 120048/30000
150060/30000 180072/30000
210084/30000 240096/30000
270108/30000 300120/30000
...

Test 36

Verdict: ACCEPTED

input
318

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 37

Verdict: ACCEPTED

input
319

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 38

Verdict: ACCEPTED

input
320

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 39

Verdict:

input
500

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30006/30000 60012/30000
90018/30000 120024/30000
150030/30000 180036/30000
210042/30000 240048/30000
270054/30000 300060/30000
...

Test 40

Verdict: ACCEPTED

input
990

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 41

Verdict: ACCEPTED

input
996

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 42

Verdict: ACCEPTED

input
997

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 43

Verdict: ACCEPTED

input
998

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 44

Verdict: ACCEPTED

input
999

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
2/2 4/2
6/2 8/2
10/2 12/2
14/2 16/2
18/2 20/2
...

Test 45

Verdict:

input
1000

correct output
0/1000000 1000000/1000000
2000000/1000000 3000000/100000...

user output
30001/30000 60002/30000
90003/30000 120004/30000
150005/30000 180006/30000
210007/30000 240008/30000
270009/30000 300010/30000
...