Submission #939355

# Submission time Handle Problem Language Result Execution time Memory
939355 2024-03-06T09:48:00 Z ifateen Combo (IOI18_combo) C++14
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

string guess_sequence(int N) {
    string ans;
    vector<string> possible = {"A", "B", "X", "Y"};
    int idx = -1;
    for (int i = 0; i < possible.size() - 1; i++) {
        int ret = press(possible[i]);
        if (ret == 1) {
            ans += possible[i];
            idx = i;
            break;
        }
    }
    if (ans.empty()) ans += "Y", idx = 3;
    swap(possible[idx], possible[3]);
    while (ans.size() < N) {
        string query;
        query += ans;
        query += possible[1];
        query += ans;
        query += possible[2];
        query += possible[0];
        query += ans;
        query += possible[2];
        query += possible[1];
        query += ans;
        query += possible[2];
        query += possible[2];
        int ret_value = press(query);
        if (ret_value == ans.size()) {
            // possible[0]
            ans += possible[0];
        } else if (ret_value == ans.size() + 1) {
            // possible[1]
            ans += possible[1];
        } else ans += possible[2];
    }
    return ans;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:9:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for (int i = 0; i < possible.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:19:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     while (ans.size() < N) {
      |            ~~~~~~~~~~~^~~
combo.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if (ret_value == ans.size()) {
      |             ~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:36:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         } else if (ret_value == ans.size() + 1) {
      |                    ~~~~~~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer: invalid press
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB Wrong Answer: invalid press
6 Halted 0 ms 0 KB -