Submission #795877

# Submission time Handle Problem Language Result Execution time Memory
795877 2023-07-27T19:11:22 Z sadsa Combo (IOI18_combo) C++17
97 / 100
30 ms 604 KB
#include "combo.h"

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

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

using i64 = int64_t;
using vl = vector<i64>;
using ll = pair<i64, i64>;
using vll = vector<ll>;

constexpr int iINF = numeric_limits<int>::max();
constexpr i64 lINF = numeric_limits<i64>::max();

#define RANGE(x) begin(x), end(x)

template <typename... T>
void DBG(T&&... args) {
    //((cerr << args << ' '), ...) << '\n';
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &vec) {
    out << '{';
    for (size_t i = 0; i < vec.size()-1; ++i)
        out << vec[i] << ", ";
    out << vec.back() << '}';
    return out;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &pr) {
    out << '(' << pr.first << ", " << pr.second << ')';
    return out;
}

std::string guess_sequence(int N) {
    vector<char> chars{'A', 'B', 'X'};
    string p;
    for (char c : chars) {
        if (press(string(1, c))) {
            p = string(1, c);
            break;
        }
    }

    if (p.empty()) {
        p = string(1, 'Y');
    } else {
        chars.erase(find(RANGE(chars), p[0]));
        chars.push_back('Y');
    }

    DBG(p);

    for (int i = 1; i < N - 1; ++i) {
        string test = p + chars[0];
        for (char c : chars) test += p + chars[1] + c;

        DBG(p);
        DBG(test, test.size());

        int coins = press(test);
        if (coins == i) {
            p += chars[2];
        } else if (coins == i+1) {
            p += chars[0];
        } else if (coins == i+2) {
            p += chars[1];
        } else {
            while (1) new int;
        }
    }

    if (N == 1) return p;

    DBG(p);
    string test;

    if (press(test = p + chars[0]) == N) return test;
    else if (press(test = p + chars[1]) == N) return test;

    return p + chars[2];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 0 ms 208 KB Output is correct
17 Correct 0 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 0 ms 208 KB Output is correct
20 Correct 0 ms 208 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 0 ms 208 KB Output is correct
24 Correct 0 ms 208 KB Output is correct
25 Correct 0 ms 208 KB Output is correct
26 Correct 0 ms 208 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 0 ms 208 KB Output is correct
29 Correct 0 ms 208 KB Output is correct
30 Correct 0 ms 208 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Correct 0 ms 208 KB Output is correct
35 Correct 0 ms 208 KB Output is correct
36 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Partially correct 0 ms 208 KB Output is partially correct
13 Partially correct 0 ms 208 KB Output is partially correct
14 Correct 0 ms 208 KB Output is correct
15 Partially correct 0 ms 208 KB Output is partially correct
16 Partially correct 0 ms 208 KB Output is partially correct
17 Correct 22 ms 392 KB Output is correct
18 Correct 17 ms 384 KB Output is correct
19 Correct 18 ms 388 KB Output is correct
20 Partially correct 25 ms 556 KB Output is partially correct
21 Partially correct 19 ms 484 KB Output is partially correct
22 Correct 0 ms 208 KB Output is correct
23 Partially correct 1 ms 208 KB Output is partially correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 1 ms 300 KB Output is correct
27 Correct 2 ms 208 KB Output is correct
28 Correct 2 ms 208 KB Output is correct
29 Partially correct 1 ms 320 KB Output is partially correct
30 Correct 2 ms 336 KB Output is correct
31 Partially correct 2 ms 316 KB Output is partially correct
32 Partially correct 17 ms 392 KB Output is partially correct
33 Correct 17 ms 388 KB Output is correct
34 Correct 21 ms 588 KB Output is correct
35 Partially correct 17 ms 460 KB Output is partially correct
36 Partially correct 23 ms 388 KB Output is partially correct
37 Correct 24 ms 388 KB Output is correct
38 Partially correct 18 ms 392 KB Output is partially correct
39 Correct 22 ms 552 KB Output is correct
40 Correct 20 ms 388 KB Output is correct
41 Partially correct 25 ms 392 KB Output is partially correct
42 Correct 22 ms 384 KB Output is correct
43 Correct 18 ms 384 KB Output is correct
44 Correct 20 ms 440 KB Output is correct
45 Correct 10 ms 392 KB Output is correct
46 Correct 23 ms 384 KB Output is correct
47 Correct 20 ms 384 KB Output is correct
48 Partially correct 23 ms 384 KB Output is partially correct
49 Partially correct 27 ms 384 KB Output is partially correct
50 Correct 19 ms 388 KB Output is correct
51 Correct 19 ms 604 KB Output is correct
52 Partially correct 21 ms 384 KB Output is partially correct
53 Partially correct 23 ms 504 KB Output is partially correct
54 Correct 22 ms 424 KB Output is correct
55 Correct 16 ms 392 KB Output is correct
56 Correct 18 ms 388 KB Output is correct
57 Correct 23 ms 392 KB Output is correct
58 Correct 22 ms 388 KB Output is correct
59 Correct 20 ms 388 KB Output is correct
60 Partially correct 22 ms 388 KB Output is partially correct
61 Partially correct 25 ms 388 KB Output is partially correct
62 Correct 24 ms 404 KB Output is correct
63 Correct 13 ms 384 KB Output is correct
64 Partially correct 19 ms 464 KB Output is partially correct
65 Partially correct 14 ms 384 KB Output is partially correct
66 Correct 22 ms 468 KB Output is correct
67 Correct 20 ms 388 KB Output is correct
68 Partially correct 24 ms 384 KB Output is partially correct
69 Correct 21 ms 492 KB Output is correct
70 Correct 23 ms 384 KB Output is correct
71 Correct 17 ms 480 KB Output is correct
72 Correct 23 ms 400 KB Output is correct
73 Partially correct 19 ms 400 KB Output is partially correct
74 Correct 30 ms 388 KB Output is correct
75 Correct 16 ms 384 KB Output is correct
76 Partially correct 16 ms 580 KB Output is partially correct
77 Correct 23 ms 388 KB Output is correct
78 Correct 1 ms 208 KB Output is correct
79 Partially correct 1 ms 208 KB Output is partially correct
80 Correct 1 ms 208 KB Output is correct
81 Partially correct 1 ms 208 KB Output is partially correct
82 Partially correct 1 ms 208 KB Output is partially correct
83 Correct 1 ms 208 KB Output is correct
84 Correct 0 ms 208 KB Output is correct
85 Partially correct 1 ms 208 KB Output is partially correct
86 Correct 1 ms 208 KB Output is correct
87 Partially correct 1 ms 208 KB Output is partially correct
88 Correct 0 ms 208 KB Output is correct
89 Correct 0 ms 208 KB Output is correct
90 Correct 1 ms 208 KB Output is correct
91 Correct 1 ms 208 KB Output is correct
92 Correct 1 ms 208 KB Output is correct
93 Correct 1 ms 208 KB Output is correct
94 Partially correct 1 ms 208 KB Output is partially correct
95 Partially correct 1 ms 208 KB Output is partially correct
96 Correct 1 ms 208 KB Output is correct
97 Correct 1 ms 208 KB Output is correct
98 Partially correct 1 ms 208 KB Output is partially correct
99 Partially correct 1 ms 208 KB Output is partially correct
100 Correct 1 ms 208 KB Output is correct
101 Correct 1 ms 208 KB Output is correct
102 Correct 1 ms 208 KB Output is correct
103 Correct 1 ms 208 KB Output is correct
104 Correct 1 ms 208 KB Output is correct
105 Correct 0 ms 208 KB Output is correct
106 Partially correct 1 ms 208 KB Output is partially correct
107 Partially correct 0 ms 208 KB Output is partially correct
108 Correct 0 ms 208 KB Output is correct
109 Correct 0 ms 208 KB Output is correct
110 Partially correct 1 ms 208 KB Output is partially correct
111 Partially correct 0 ms 208 KB Output is partially correct
112 Correct 1 ms 208 KB Output is correct
113 Correct 1 ms 208 KB Output is correct
114 Partially correct 0 ms 208 KB Output is partially correct
115 Partially correct 1 ms 208 KB Output is partially correct
116 Correct 1 ms 208 KB Output is correct
117 Correct 1 ms 208 KB Output is correct
118 Correct 1 ms 208 KB Output is correct
119 Partially correct 1 ms 208 KB Output is partially correct
120 Correct 1 ms 208 KB Output is correct
121 Correct 1 ms 300 KB Output is correct
122 Partially correct 2 ms 208 KB Output is partially correct
123 Partially correct 1 ms 208 KB Output is partially correct