제출 #393684

#제출 시각아이디문제언어결과실행 시간메모리
393684phathnv콤보 (IOI18_combo)C++11
5 / 100
2 ms276 KiB
#include<bits/stdc++.h>
#include "combo.h"

using namespace std;

string guess_sequence(int n) {
    char c[4] = {'A', 'B', 'X', 'Y'};
    int l = 0, r = 3;
    while (l < r){
        int mid = (l + r) >> 1;
        string tmp;
        for(int i = l; i <= mid; i++)
            tmp.push_back(c[i]);
        if (press(tmp) > 0)
            r = mid;
        else
            l = mid + 1;
    }
    swap(c[3], c[l]);
    string s;
    s.push_back(c[3]);
    while (s.size() < n - 1){
		string q = s + c[1] + s + c[2] + c[0] + s + c[2] + c[1] + s + c[2] + c[2];
		s += c[press(q) - s.size()];
	}

	if (press(s + c[0]) == n)
		s += c[0];
	else if (press(s + c[1]) == n)
		s += c[1];
	else
		s += c[2];

    return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |     while (s.size() < n - 1){
      |            ~~~~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...