File size: 20,131 Bytes
5fed0fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

struct Card {
    int color, value;
    Card(): color(-1), value(-1) {}
    Card(int _color, int _value): color(_color), value(_value) {}
};

struct State {
    Card alice[2], bob[2];
    Card community[5];
};

enum class ActionType {
    CHECK, CALL, RAISE, FOLD
};

namespace {

// hand evaluation
enum class HandType {
    StraightFlush = 8,
    Four = 7,
    FullHouse = 6,
    Flush = 5,
    Straight = 4,
    Three = 3,
    TwoPair = 2,
    Pair = 1,
    HighCard = 0
};

struct Score {
    HandType w;
    int hash_value;
    Score() : w(HandType::HighCard), hash_value(0) {}
    Score(HandType _w, vector<int>& A) {
        w = _w; hash_value = 0;
        for (int i = 0; i < (int)A.size(); ++i) {
            hash_value = hash_value * 20 + A[i];
        }
    }
};

bool operator<(const Score& k1, const Score& k2) {
    if (k1.w != k2.w) return k1.w < k2.w;
    return k1.hash_value < k2.hash_value;
}

struct CardCmp {
    bool operator () (const Card& x, const Card& y) const {
        return x.value < y.value || (x.value == y.value && x.color < y.color);
    }
};

bool is_card_used[14][5];
int used_num[14];

bool isValidCard(const Card& card) {
    return 1 <= card.value && card.value <= 13 && 0 <= card.color && card.color <= 3;
}

void assertCompleteStateOrFail(const State& s) {
    static set<Card, CardCmp> S;
    S.clear();
    for (int i = 0; i < 2; ++i) {
        ensuref(isValidCard(s.alice[i]), "Internal error: invalid Alice card in complete state");
        ensuref(S.find(s.alice[i]) == S.end(), "Internal error: duplicate card in complete state");
        S.insert(s.alice[i]);
        ensuref(isValidCard(s.bob[i]), "Internal error: invalid Bob card in complete state");
        ensuref(S.find(s.bob[i]) == S.end(), "Internal error: duplicate card in complete state");
        S.insert(s.bob[i]);
    }
    for (int i = 0; i < 5; ++i) {
        ensuref(isValidCard(s.community[i]), "Internal error: invalid community card in complete state");
        ensuref(S.find(s.community[i]) == S.end(), "Internal error: duplicate card in complete state");
        S.insert(s.community[i]);
    }
}

// forward rngs
mt19937_64 rng_sampling; // for RATE queries and BobAction sampling

bool checkStraightFlush(Score& res) {
    for (int c = 0; c < 4; ++c) {
        for (int i = 9; i >= 0; --i) {
            int flag = 0;
            for (int j = 0; j <= 4; ++j)
                if (!is_card_used[i + j][c]) {
                    flag = 1;
                    break;
                }
            if (flag) continue;
            vector<int> A;
            for (int j = 4; j >= 0; j--) A.push_back(i + j);
            res = Score(HandType::StraightFlush, A);
            return true;
        }
    }
    return false;
}

bool checkFour(Score& res) {
    for (int i = 13; i; i--)
        if (used_num[i] == 4) {
            vector<int> A;
            for (int k = 0; k < 4; k++) A.push_back(i);
            for (int j = 13; j; j--)
                if (i != j && used_num[j]) {
                    A.push_back(j);
                    res = Score(HandType::Four, A);
                    return true;
                }
        }
    return false;
}

bool checkFullHouse(Score &res) {
    for (int i = 13; i; i--)
        if (used_num[i] == 3) {
            vector<int> A;
            for (int k = 0; k < 3; k++) A.push_back(i);
            for (int j = 13; j; j--)
                if (i != j && used_num[j] >= 2) {
                    for (int k = 0; k < 2; k++) A.push_back(j);
                    res = Score(HandType::FullHouse, A);
                    return true;
                }
        }
    return false;
}

bool checkFlush(Score &res) {
    for (int c = 0; c < 4; c++) {
        vector<int> A;
        for (int i = 13; i; i--)
            if (is_card_used[i][c]) {
                A.push_back(i);
                if ((int)A.size() == 5) {
                    res = Score(HandType::Flush, A);
                    return true;
                }
            }
    }
    return false;
}

bool checkStraight(Score &res) {
    for (int i = 9; i >= 0; i--) {
        int flag = 0;
        for (int j = 4; j >= 0; j--)
            if (!used_num[i + j]) {
                flag = 1;
                break;
            }
        if (flag) continue;
        vector<int> A;
        for (int j = 4; j >= 0; j--)
            A.push_back(i + j);
        res = Score(HandType::Straight, A);
        return true;
    }
    return false;
}

bool checkThree(Score &res) {
    for (int i = 13; i; i--)
        if (used_num[i] >= 3) {
            vector<int> A;
            for (int k = 0; k < 3; k++) A.push_back(i);
            for (int j = 13; j; j--)
                if (used_num[j] && j != i) {
                    A.push_back(j);
                    if ((int)A.size() == 5) {
                        res = Score(HandType::Three, A);
                        return true;
                    }
                }
        }
    return false;
}

bool checkTwoPair(Score &res) {
    for (int i = 13; i; i--)
        if (used_num[i] >= 2) {
            vector<int> A;
            for (int k = 0; k < 2; k++) A.push_back(i);
            for (int j = i - 1; j; j--)
                if (used_num[j] >= 2) {
                    for (int k = 0; k < 2; k++) A.push_back(j);
                    for (int x = 13; x; x--)
                        if (used_num[x] && x != i && x != j) {
                            A.push_back(x);
                            res = Score(HandType::TwoPair, A);
                            return true;
                        }
                }
        }
    return false;
}

bool checkPair(Score &res) {
    for (int i = 13; i; i--)
        if (used_num[i] >= 2) {
            vector<int> A;
            for (int k = 0; k < 2; k++) A.push_back(i);
            for (int j = 13; j; j--)
                if (used_num[j] && j != i) {
                    A.push_back(j);
                    if ((int)A.size() == 5) {
                        res = Score(HandType::Pair, A);
                        return true;
                    }
                }
        }
    return false;
}

void getHighCard(Score &res) {
    vector<int> A;
    for (int i = 13; i; i--)
        if (used_num[i]) {
            A.push_back(i);
            if ((int)A.size() == 5) {
                res = Score(HandType::HighCard, A);
                return;
            }
        }
}

Score getScoreForHand(vector<Card>& A) {
    memset(is_card_used, 0x00, sizeof is_card_used);
    memset(used_num, 0x00, sizeof used_num);
    for (int i = 0; i < (int)A.size(); ++i) {
        is_card_used[A[i].value][A[i].color] = true;
        ++used_num[A[i].value];
    }
    used_num[0] = used_num[13];
    for (int i = 0; i <= 4; i++) {
        is_card_used[0][i] = is_card_used[13][i];
    }
    Score res;
    if (checkStraightFlush(res)) return res;
    if (checkFour(res)) return res;
    if (checkFullHouse(res)) return res;
    if (checkFlush(res)) return res;
    if (checkStraight(res)) return res;
    if (checkThree(res)) return res;
    if (checkTwoPair(res)) return res;
    if (checkPair(res)) return res;
    getHighCard(res);
    return res;
}

int getResult(const State& s) {
    vector<Card> alice, bob;
    assertCompleteStateOrFail(s);
    for (int i = 0; i < 2; ++i) {
        alice.push_back(s.alice[i]);
        bob.push_back(s.bob[i]);
    }
    for (int i = 0; i < 5; ++i) {
        alice.push_back(s.community[i]);
        bob.push_back(s.community[i]);
    }
    Score alice_score = getScoreForHand(alice);
    Score bob_score = getScoreForHand(bob);
    if (alice_score < bob_score) return -1;
    if (bob_score < alice_score) return 1;
    return 0;
}

pair<double, double> getRatesBySampling(const State& s, int t) {
    memset(is_card_used, 0x00, sizeof is_card_used);
    auto deal_with_card = [&](const Card& c) {
        if (isValidCard(c)) {
            ensuref(!is_card_used[c.value][c.color], "Internal error: duplicate card in partial state");
            is_card_used[c.value][c.color] = true;
        }
    };
    for (int i = 0; i < 2; ++i) {
        deal_with_card(s.alice[i]);
        deal_with_card(s.bob[i]);
    }
    for (int i = 0; i < 5; ++i) {
        deal_with_card(s.community[i]);
    }
    vector<Card> remaining_card;
    for (int i = 1; i <= 13; ++i) {
        for (int j = 0; j < 4; ++j) {
            if (!is_card_used[i][j]) {
                remaining_card.emplace_back(j, i);
            }
        }
    }
    int win_num = 0, draw_num = 0;
    for (int _ = 0; _ < t; ++_) {
        State complete_s = s;
        shuffle(remaining_card.begin(), remaining_card.end(), rng_sampling);
        int ind = 0;
        for (int i = 0; i < 2; ++i) {
            if (!isValidCard(s.alice[i])) {
                complete_s.alice[i] = remaining_card[ind++];
            }
            if (!isValidCard(s.bob[i])) {
                complete_s.bob[i] = remaining_card[ind++];
            }
        }
        for (int i = 0; i < 5; ++i) {
            if (!isValidCard(s.community[i])) {
                complete_s.community[i] = remaining_card[ind++];
            }
        }
        auto result = getResult(complete_s);
        if (result == 1) {
            ++win_num;
        } else if (result == 0) {
            ++draw_num;
        }
    }
    return make_pair(1.0 * win_num / t, 1.0 * draw_num / t);
}

State getPartialState(const State& complete_state, int round_index_0based, int player /*0 alice sees, 1 bob sees*/) {
    // round_index_0based: 0 -> preflop (k=0), 1 -> flop (k=3), 2 -> turn (k=4), 3 -> river (k=5)
    int num = 0;
    if (round_index_0based == 0) num = 0;
    else num = 2 + round_index_0based; // 1->3, 2->4, 3->5
    State s = complete_state;
    for (int i = num; i < 5; ++i) {
        s.community[i] = Card();
    }
    if (player == 0) {
        // hide Bob's cards from Alice
        for (int i = 0; i < 2; ++i) {
            s.bob[i] = Card();
        }
    } else {
        // hide Alice's cards from Bob
        for (int i = 0; i < 2; ++i) {
            s.alice[i] = Card();
        }
    }
    return s;
}

pair<ActionType, int> BobAction(const State& s /*partial from Bob's view*/, int rise, int pool_value) {
    pair<double, double> rates = getRatesBySampling(s, 100);
    double w = rates.first, d = rates.second;
    // Bob's expected value if she calls now (relative to current point):
    // win: pool + rise; tie: pool/2; lose: -rise
    double expected_call = -w * rise + d * (pool_value / 2.0) + (1 - w - d) * (pool_value + rise);
    if (expected_call > 0) return make_pair(ActionType::CALL, 0);
    return make_pair(ActionType::FOLD, 0);
}

// helper for formatting/printing doubles
string fmt2(const string& head, double a, double b) {
    ostringstream oss;
    oss.setf(std::ios::fixed); oss<<setprecision(6);
    oss<<head<<" "<<a<<" "<<b;
    return oss.str();
}
string fmt1(const string& head, double a) {
    ostringstream oss;
    oss.setf(std::ios::fixed); oss<<setprecision(6);
    oss<<head<<" "<<a;
    return oss.str();
}

} // namespace

// Generate a full deck order from a seed
vector<Card> generate_deck_from_seed(uint64_t seed) {
    vector<Card> deck;
    deck.reserve(52);
    for (int v = 1; v <= 13; ++v) {
        for (int s = 0; s < 4; ++s) {
            deck.emplace_back(s, v);
        }
    }
    mt19937_64 eng(seed);
    shuffle(deck.begin(), deck.end(), eng);
    // sanity uniqueness
    set<pair<int,int>> S;
    for (auto &c: deck) {
        ensuref(1 <= c.value && c.value <= 13 && 0 <= c.color && c.color <= 3, "Internal error: bad card generated");
        ensuref(S.insert({c.color, c.value}).second, "Internal error: duplicate in generated deck");
    }
    return deck;
}

int compute_points_from_W(double W) {
    // piecewise linear to integer points in [0,100]
    if (W <= 8.0) return 0;
    if (W <= 11.0) {
        double x = 13.3 * (W - 8.0);              // 0 -> 40 over (8,11]
        return (int) llround(x);
    }
    if (W <= 14.0) {
        double x = 40.0 + 14.0 * (W - 11.0);      // 40 -> 82 over (11,14]
        return (int) llround(x);
    }
    if (W <= 20.0) {
        double x = 82.0 + 3.0 * (W - 14.0);       // 82 -> 100 over (14,20]
        return (int) llround(x);
    }
    return 100;
}

double compute_points_unbounded(double W) {
    if (W <= 8.0) return 0.0;
    if (W <= 11.0) {
        double x = 13.3 * (W - 8.0);
        return (double) llround(x);
    }
    if (W <= 14.0) {
        double x = 40.0 + 14.0 * (W - 11.0);
        return (double) llround(x);
    }
    double x = 82.0 + 3.0 * (W - 14.0);
    return (double) llround(x);
}

int main(int argc, char* argv[]) {
    registerInteraction(argc, argv);

    // Read public G from .in
    int G = inf.readInt();
    println(G); // send G to contestant

    // Read hidden seeds from .ans
    long long sampling_seed = ans.readLong(); // global sampling seed
    int G_ans = ans.readInt();
    ensuref(G_ans >= G, "ANS file has fewer hand seeds (%d) than required hands (%d)", G_ans, G);
    vector<uint64_t> hand_seeds(G_ans);
    for (int i = 0; i < G_ans; ++i) {
        hand_seeds[i] = (uint64_t) ans.readLong();
    }
    rng_sampling.seed((uint64_t)sampling_seed);

    const long long RATE_BUDGET = 3000000LL;
    long long used_rate_budget = 0;

    auto print_state = [&](int h, int r, int a, int b, int P, int k, const State& complete_state) {
        // STATE h r a b P k
        {
            ostringstream oss;
            oss<<"STATE "<<h<<" "<<r<<" "<<a<<" "<<b<<" "<<P<<" "<<k;
            println(oss.str());
        }
        // ALICE c1 v1 c2 v2
        {
            ostringstream oss;
            oss<<"ALICE "<<complete_state.alice[0].color<<" "<<complete_state.alice[0].value<<" "
               <<complete_state.alice[1].color<<" "<<complete_state.alice[1].value;
            println(oss.str());
        }
        // BOARD ...
        {
            ostringstream oss;
            oss<<"BOARD";
            for (int i = 0; i < k; ++i) {
                oss<<" "<<complete_state.community[i].color<<" "<<complete_state.community[i].value;
            }
            println(oss.str());
        }
    };

    auto showdown_delta = [&](int a, int P, const State& complete_state)->int {
        int result = getResult(complete_state);
        if (result == 1) return (a + P) - 100;
        if (result == 0) return (a + P / 2) - 100;
        return a - 100;
    };

    long long total_delta_sum = 0;

    for (int h = 1; h <= G; ++h) {
        // Generate deck for this hand
        vector<Card> deck = generate_deck_from_seed(hand_seeds[h-1]);
        State complete_state;
        // deal: Alice[0..1], Bob[0..1], Community[0..4]
        complete_state.alice[0] = deck[0];
        complete_state.alice[1] = deck[1];
        complete_state.bob[0]   = deck[2];
        complete_state.bob[1]   = deck[3];
        for (int i = 0; i < 5; ++i) {
            complete_state.community[i] = deck[4 + i];
        }

        int a = 100, b = 100, P = 10;
        bool hand_ended = false;

        for (int r = 1; r <= 4 && !hand_ended; ++r) {
            int k = 0;
            if (r == 1) k = 0;
            else if (r == 2) k = 3;
            else if (r == 3) k = 4;
            else if (r == 4) k = 5;

            // send state
            print_state(h, r, a, b, P, k, complete_state);

            // handle RATE queries and then one ACTION
            while (true) {
                string cmd = ouf.readToken();
                if (cmd == "-1") {
                    quitp(0.0, "Contestant terminated with -1");
                } else if (cmd == "RATE") {
                    long long t = ouf.readLong(1, (long long)1e9);
                    if (used_rate_budget + t > RATE_BUDGET) {
                        println("-1");
                        quitp(0.0, "RATE budget exceeded. Used %lld, requested %lld, budget %lld",
                              used_rate_budget, t, RATE_BUDGET);
                    }
                    State partial_for_alice = getPartialState(complete_state, r - 1, 0);
                    auto rates = getRatesBySampling(partial_for_alice, (int)t);
                    used_rate_budget += t;
                    println(fmt2("RATES", rates.first, rates.second));
                } else if (cmd == "ACTION") {
                    string act = ouf.readToken();
                    if (act == "CHECK") {
                        // Bob always checks
                        println("OPP CHECK");
                        if (r == 4) {
                            int delta = showdown_delta(a, P, complete_state);
                            total_delta_sum += delta;
                            {
                                ostringstream oss;
                                oss<<"RESULT "<<delta;
                                println(oss.str());
                            }
                            hand_ended = true;
                        }
                        break;
                    } else if (act == "FOLD") {
                        int delta = a - 100;
                        total_delta_sum += delta;
                        {
                            ostringstream oss;
                            oss<<"RESULT "<<delta;
                            println(oss.str());
                        }
                        hand_ended = true;
                        break;
                    } else if (act == "RAISE") {
                        int x = ouf.readInt();
                        if (x < 1 || x > a) {
                            quitf(_wa, "Invalid RAISE amount x=%d; must be in [1, %d]", x, a);
                        }
                        // Bob decision before updating stacks/pot
                        State bob_view = getPartialState(complete_state, r - 1, 1);
                        auto bob_dec = BobAction(bob_view, x, P);
                        if (bob_dec.first == ActionType::FOLD) {
                            println("OPP FOLD");
                            // If Bob folds, final stack for Alice: a + P (independent of x)
                            int delta = a + P - 100;
                            total_delta_sum += delta;
                            {
                                ostringstream oss;
                                oss<<"RESULT "<<delta;
                                println(oss.str());
                            }
                            hand_ended = true;
                        } else {
                            // CALL
                            println(string("OPP CALL ") + to_string(x));
                            // both invest x, pot + 2x
                            a -= x;
                            b -= x;
                            P += 2 * x;
                            if (r == 4) {
                                int delta = showdown_delta(a, P, complete_state);
                                total_delta_sum += delta;
                                {
                                    ostringstream oss;
                                    oss<<"RESULT "<<delta;
                                    println(oss.str());
                                }
                                hand_ended = true;
                            }
                        }
                        break;
                    } else {
                        quitf(_wa, "Invalid ACTION type: %s", act.c_str());
                    }
                } else {
                    quitf(_wa, "Invalid command before ACTION: %s (expected RATE or ACTION)", cmd.c_str());
                }
            } // end command loop
        } // end rounds
    } // end hands

    double W = (double)total_delta_sum / (double)G;
    println(fmt1("SCORE", W));
    int points = compute_points_from_W(W);
    double ratio = points / 100.0;
    double points_unbounded = compute_points_unbounded(W);
    double ratio_unbounded = points_unbounded / 100.0;
    quitp(ratio, "Average profit W: %.6f, points: %d, Ratio: %.4f, RatioUnbounded: %.4f",
          W, points, ratio, ratio_unbounded);
    return 0;
}