Submission #497242

# Submission time Handle Problem Language Result Execution time Memory
497242 2021-12-22T20:07:24 Z pakhomovee Combo (IOI18_combo) C++17
97 / 100
28 ms 552 KB
#include "combo.h"
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

int press(string p);

string guess_sequence(int N) {
    vector<char> v = { 'A', 'B', 'X', 'Y' };
    string res;
    for (int i = 0; i < 3; ++i) {
        string curr;
        curr += v[i];
        if (press(curr)) {
            res += v[i];
            break;
        }
    }
    if (res.size() == 0) {
        res += 'Y';
    }
    v.erase(find(v.begin(), v.end(), res[0]));
    int ptr = 1;
    while (ptr + 1 < N) {
        string query = res;
        query += v[0];
        query += res;
        query += v[1];
        query += v[0];
        query += res;
        query += v[1];
        query += v[1];
        query += res;
        query += v[1];
        query += v[2];
        assert(query.size() <= N * 4);
        int c = press(query);
        if (c == ptr) {
            res += v[2];
        } else if (c == ptr + 1) {
            res += v[0];
        } else {
            res += v[1];
        }
        ++ptr;
    }
    if (ptr < N) {
        for (int i = 0; i < 2; ++i) {
            string curr = res;
            curr += v[i];
            if (press(curr) == N) {
                res += v[i];
                break;
            }
        }
        if (res.size() < N) {
            res += v[2];
        }
    }
    v = { 'A', 'B', 'X', 'Y' };
    return res;
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from combo.cpp:4:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:29: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |         assert(query.size() <= N * 4);
      |                ~~~~~~~~~~~~~^~~~~~~~
combo.cpp:58:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |         if (res.size() < N) {
      |             ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 0 ms 200 KB Output is correct
12 Correct 0 ms 200 KB Output is correct
13 Correct 0 ms 200 KB Output is correct
14 Correct 0 ms 200 KB Output is correct
15 Correct 0 ms 200 KB Output is correct
16 Correct 0 ms 216 KB Output is correct
17 Correct 0 ms 216 KB Output is correct
18 Correct 0 ms 216 KB Output is correct
19 Correct 0 ms 216 KB Output is correct
20 Correct 0 ms 200 KB Output is correct
21 Correct 0 ms 200 KB Output is correct
22 Correct 0 ms 200 KB Output is correct
23 Correct 0 ms 200 KB Output is correct
24 Correct 0 ms 200 KB Output is correct
25 Correct 0 ms 208 KB Output is correct
26 Correct 0 ms 216 KB Output is correct
27 Correct 0 ms 216 KB Output is correct
28 Correct 1 ms 216 KB Output is correct
29 Correct 0 ms 216 KB Output is correct
30 Correct 0 ms 216 KB Output is correct
31 Correct 1 ms 216 KB Output is correct
32 Correct 0 ms 216 KB Output is correct
33 Correct 0 ms 216 KB Output is correct
34 Correct 0 ms 216 KB Output is correct
35 Correct 0 ms 200 KB Output is correct
36 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 0 ms 200 KB Output is correct
12 Partially correct 0 ms 200 KB Output is partially correct
13 Partially correct 0 ms 200 KB Output is partially correct
14 Correct 0 ms 200 KB Output is correct
15 Partially correct 0 ms 200 KB Output is partially correct
16 Partially correct 0 ms 200 KB Output is partially correct
17 Correct 26 ms 328 KB Output is correct
18 Correct 21 ms 328 KB Output is correct
19 Correct 26 ms 332 KB Output is correct
20 Partially correct 25 ms 336 KB Output is partially correct
21 Partially correct 19 ms 536 KB Output is partially correct
22 Correct 0 ms 200 KB Output is correct
23 Partially correct 1 ms 200 KB Output is partially correct
24 Correct 1 ms 200 KB Output is correct
25 Correct 1 ms 280 KB Output is correct
26 Correct 1 ms 200 KB Output is correct
27 Correct 2 ms 200 KB Output is correct
28 Correct 2 ms 200 KB Output is correct
29 Partially correct 1 ms 200 KB Output is partially correct
30 Correct 2 ms 276 KB Output is correct
31 Partially correct 2 ms 200 KB Output is partially correct
32 Partially correct 26 ms 456 KB Output is partially correct
33 Correct 24 ms 400 KB Output is correct
34 Correct 25 ms 336 KB Output is correct
35 Partially correct 21 ms 336 KB Output is partially correct
36 Partially correct 27 ms 328 KB Output is partially correct
37 Correct 20 ms 500 KB Output is correct
38 Partially correct 25 ms 388 KB Output is partially correct
39 Correct 25 ms 408 KB Output is correct
40 Correct 18 ms 488 KB Output is correct
41 Partially correct 23 ms 432 KB Output is partially correct
42 Correct 28 ms 332 KB Output is correct
43 Correct 27 ms 552 KB Output is correct
44 Correct 15 ms 328 KB Output is correct
45 Correct 26 ms 332 KB Output is correct
46 Correct 26 ms 328 KB Output is correct
47 Correct 23 ms 328 KB Output is correct
48 Partially correct 16 ms 448 KB Output is partially correct
49 Partially correct 22 ms 444 KB Output is partially correct
50 Correct 25 ms 328 KB Output is correct
51 Correct 27 ms 456 KB Output is correct
52 Partially correct 24 ms 424 KB Output is partially correct
53 Partially correct 25 ms 396 KB Output is partially correct
54 Correct 28 ms 444 KB Output is correct
55 Correct 27 ms 344 KB Output is correct
56 Correct 26 ms 332 KB Output is correct
57 Correct 22 ms 412 KB Output is correct
58 Correct 25 ms 388 KB Output is correct
59 Correct 28 ms 336 KB Output is correct
60 Partially correct 21 ms 376 KB Output is partially correct
61 Partially correct 24 ms 332 KB Output is partially correct
62 Correct 27 ms 432 KB Output is correct
63 Correct 22 ms 392 KB Output is correct
64 Partially correct 27 ms 396 KB Output is partially correct
65 Partially correct 23 ms 380 KB Output is partially correct
66 Correct 24 ms 420 KB Output is correct
67 Correct 24 ms 328 KB Output is correct
68 Partially correct 24 ms 520 KB Output is partially correct
69 Correct 26 ms 416 KB Output is correct
70 Correct 21 ms 332 KB Output is correct
71 Correct 28 ms 432 KB Output is correct
72 Correct 20 ms 432 KB Output is correct
73 Partially correct 11 ms 324 KB Output is partially correct
74 Correct 22 ms 336 KB Output is correct
75 Correct 25 ms 328 KB Output is correct
76 Partially correct 25 ms 440 KB Output is partially correct
77 Correct 22 ms 424 KB Output is correct
78 Correct 0 ms 200 KB Output is correct
79 Partially correct 0 ms 200 KB Output is partially correct
80 Correct 0 ms 200 KB Output is correct
81 Partially correct 1 ms 200 KB Output is partially correct
82 Partially correct 1 ms 200 KB Output is partially correct
83 Correct 0 ms 200 KB Output is correct
84 Correct 1 ms 200 KB Output is correct
85 Partially correct 1 ms 200 KB Output is partially correct
86 Correct 1 ms 200 KB Output is correct
87 Partially correct 1 ms 200 KB Output is partially correct
88 Correct 0 ms 200 KB Output is correct
89 Correct 0 ms 200 KB Output is correct
90 Correct 0 ms 200 KB Output is correct
91 Correct 1 ms 200 KB Output is correct
92 Correct 0 ms 200 KB Output is correct
93 Correct 1 ms 200 KB Output is correct
94 Partially correct 1 ms 200 KB Output is partially correct
95 Partially correct 1 ms 200 KB Output is partially correct
96 Correct 1 ms 328 KB Output is correct
97 Correct 1 ms 200 KB Output is correct
98 Partially correct 1 ms 200 KB Output is partially correct
99 Partially correct 1 ms 200 KB Output is partially correct
100 Correct 1 ms 200 KB Output is correct
101 Correct 1 ms 200 KB Output is correct
102 Correct 1 ms 200 KB Output is correct
103 Correct 1 ms 200 KB Output is correct
104 Correct 1 ms 200 KB Output is correct
105 Correct 1 ms 200 KB Output is correct
106 Partially correct 0 ms 200 KB Output is partially correct
107 Partially correct 1 ms 200 KB Output is partially correct
108 Correct 0 ms 200 KB Output is correct
109 Correct 0 ms 200 KB Output is correct
110 Partially correct 0 ms 200 KB Output is partially correct
111 Partially correct 0 ms 200 KB Output is partially correct
112 Correct 0 ms 200 KB Output is correct
113 Correct 0 ms 200 KB Output is correct
114 Partially correct 0 ms 200 KB Output is partially correct
115 Partially correct 0 ms 200 KB Output is partially correct
116 Correct 0 ms 200 KB Output is correct
117 Correct 1 ms 200 KB Output is correct
118 Correct 1 ms 200 KB Output is correct
119 Partially correct 1 ms 200 KB Output is partially correct
120 Correct 1 ms 328 KB Output is correct
121 Correct 1 ms 200 KB Output is correct
122 Partially correct 1 ms 200 KB Output is partially correct
123 Partially correct 1 ms 200 KB Output is partially correct