Submission #641579

#TimeUsernameProblemLanguageResultExecution timeMemory
641579NursikCombo (IOI18_combo)C++14
30 / 100
51 ms464 KiB
#include "combo.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <bitset>
using namespace std;

#define ll long long

const ll maxn = 2e3 + 1;
vector<char> v = {'A', 'B', 'X', 'Y'};
string guess_sequence(int n) {
    string pref = "";
    int get = press("AB");
    if (get == 2){
        pref += "AB";
    }
    else if (get == 1){
        get = press("A");
        if (get == 0){
            pref += "B";
        }
        else{
            pref += "A";
        }
    }
    else{
        get = press("XY");
        if (get == 2){
            pref += "XY";
        }
        else{
            get = press("X");
            if (get == 0){
                pref += "Y";
            }
            else{
                pref += "X";
            }
        }
    }
    for (int i = (int)pref.size(); i < n; ++i){
        string a = pref + 'A' + pref + 'B';
        get = press(a);
        if (get == pref.size() + 1){
            a = pref + 'A';
            get = press(a);
            if (get == pref.size() + 1)
                pref += 'A';
            else
                pref += 'B';
        }
        else{
            a = pref + 'X';
            get = press(a);
            if (get == pref.size() + 1)
                pref += 'X';
            else
                pref += 'Y';
        }
    }
    return pref;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:66:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |         if (get == pref.size() + 1){
      |             ~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:69:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |             if (get == pref.size() + 1)
      |                 ~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:77:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |             if (get == pref.size() + 1)
      |                 ~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...