Submission #313300

# Submission time Handle Problem Language Result Execution time Memory
313300 2020-10-15T17:10:13 Z noob_c0de Combo (IOI18_combo) C++17
Compilation error
0 ms 0 KB
// author shenron
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree <T, null_type, less<T> ,rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define ar array
#define db double
const db pi = acos(-1);
string ans;
string guess_sequence(int n)
{
    string init;
    // first character
    int q1=press("AB");
    if (q1==1)
    {
        int q2=press("A");
        if (q2==1)
        {
            ans+='A';
            init="BXY";
        }
        else
        {
            ans+='B';
            init="AXY";
        }
    }
    else
    {
        int q2=press("X");
        if (q2==1)
        {
            ans+='X';
            init="ABY";
        }
        else
        {
            ans+='Y';
            init="ABX";
        }
    }
    // n-2 next character
    for (int i=1;i<n;i++)
    {
        string ask=ans+init[0];
        for (int ch=0;ch<3;ch++)
        {
            ask+=ans;
            ask+=init[1];
            ask+=init[ch];
        }
        int res=press(ask);
        if (res==ans.size()) ans+=init[2];
        else if(res==ans.size()+1) ans+=init[0];
        else ans+=init[1];
    }
    // last character
    string ask;
    for (int i=0;i<2;i++)
    {
        ask+=ans;
        ask+=init[i];
    }
    int res=press(ask);
    if (res==ans.size()) ans+=init[2];
    else
    {
        ask=ans+init[0];
        res=press(ask);
        if (res==ans.size()) ans+=init[1];
        else ans+=init[0];
    }
    return(ans);
}


Compilation message

combo.cpp: In function 'std::string guess_sequence(long long int)':
combo.cpp:18:12: error: 'press' was not declared in this scope
   18 |     int q1=press("AB");
      |            ^~~~~
combo.cpp:58:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         if (res==ans.size()) ans+=init[2];
      |             ~~~^~~~~~~~~~~~
combo.cpp:59:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         else if(res==ans.size()+1) ans+=init[0];
      |                 ~~~^~~~~~~~~~~~~~
combo.cpp:70:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     if (res==ans.size()) ans+=init[2];
      |         ~~~^~~~~~~~~~~~
combo.cpp:75:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |         if (res==ans.size()) ans+=init[1];
      |             ~~~^~~~~~~~~~~~