제출 #485498

#제출 시각아이디문제언어결과실행 시간메모리
485498Joo콤보 (IOI18_combo)C++17
5 / 100
1 ms272 KiB
#include "combo.h"
#include <bits/stdc++.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);
        }
    }

    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);

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

    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){
    cout << guess_sequence(5) << "\n";
    return 0;
}
*/

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

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