Submission #165499

#TimeUsernameProblemLanguageResultExecution timeMemory
165499qwerty234Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ft fflush(stdout)
 
 
using namespace std;
 
 
const int N = 4e5 + 123;
const int PLS = 3e5 + 123;

 
string guess_sequence(int n) { 
    int ans;
    vector <string> psb;
    psb.clear();
    string cur = "";
    ans = press("AB");
    if (ans == 2) {
        cur = "A";
        psb.pb("B");
        psb.pb("X");
        psb.pb("Y");
    } else if (ans == 1) {
        ans = press("A");
        if (ans == 1) {
            cur = "A";
            psb.pb("B");
            psb.pb("X");
            psb.pb("Y");
        } else {
            cur = "B";
            psb.pb("A");
            psb.pb("X");
            psb.pb("Y");
        }
    } else {
        ans = press("X");
        if (ans == 1) {
            cur = "X";
            psb.pb("A");
            psb.pb("B");
            psb.pb("Y");
        } else {
            cur = "Y";
            psb.pb("A");
            psb.pb("B");
            psb.pb("X");
        }
    }
    string t1, t2, t3, t4;
    t1 = psb[0];
    t2 = psb[1] + psb[0];
    t3 = psb[1] + psb[1];
    t4 = psb[1] + psb[2];
    for (int i = 2; i <= n - 1; i++) {
        ans = press(cur + t1 + cur + t2 + cur + t3 + cur + t4);
        if (ans == cur.size()) {
            cur += psb[2];
        } else if (ans == cur.size() + 1) {
            cur += psb[0];
        } else {
            cur += psb[1];
        }
    }
    if (n != 1) {
        ans = press(cur + psb[0]);
        if (ans == cur.size() + 1) {
            cur += psb[0];
        } else {
            ans = press(cur + psb[1]);
            if (ans == cur.size() + 1)
                cur += psb[1];
            else
                cur += psb[2];
        }
    }
    return cur;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:11: error: 'press' was not declared in this scope
   25 |     ans = press("AB");
      |           ^~~~~
combo.cpp:65:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         if (ans == cur.size()) {
      |             ~~~~^~~~~~~~~~~~~
combo.cpp:67:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         } else if (ans == cur.size() + 1) {
      |                    ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:75:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |         if (ans == cur.size() + 1) {
      |             ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:79:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |             if (ans == cur.size() + 1)
      |                 ~~~~^~~~~~~~~~~~~~~~~