제출 #485502

#제출 시각아이디문제언어결과실행 시간메모리
485502Joo콤보 (IOI18_combo)C++17
30 / 100
53 ms620 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

/*int press(string p){
    cout << p << "\n";
    int x; cin >> x; return x;
}*/

string guess_sequence(int N){
    string str;
    vector<char> a = {'A', 'B', 'X', 'Y'};

    if(press("AB") == 0){ ///either x or y
        if(press("X") == 1){
            str += 'X';
            a.erase(a.begin()+2);
        }else{
            str += 'Y';
            a.erase(a.begin()+3);
        }
    }else{ ///either a or b
        if(press("A") == 1){
            str += 'A';
            a.erase(a.begin());
        }else{
            str += 'B';
            a.erase(a.begin()+1);
        }
    }

    /*cout << "\n";
    for(char x : a) cout << x << " ";
    cout << "\n";*/

    for(int i = 2; i < N; i++){
        string tmp = str + a[1] + str + a[2] + a[0] + str + a[2] + a[1] + str + a[2] + a[2];
        int res = press(tmp);
        res = press(tmp);

        if(res == str.size()){ ///got nothing new
            str += a[0];
        }else if(res == str.size()+1){
            str += a[1];
        }else{
            str += a[2];
        }
    }

    if(str.size() < N){
        if(press(str+a[0]) == N){
            str += a[0];
        }else if(press(str+a[1]) == N){
            str += a[1];
        }else{
            str += a[2];
        }
    }

    return str;
}

/*
int main(void){
    int n; cin >> n;
    cout << guess_sequence(n) << "\n";
    return 0;
}
*/

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:42:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         if(res == str.size()){ ///got nothing new
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:44:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         }else if(res == str.size()+1){
      |                  ~~~~^~~~~~~~~~~~~~~
combo.cpp:51:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |     if(str.size() < N){
      |        ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...