제출 #228376

#제출 시각아이디문제언어결과실행 시간메모리
228376hhh07콤보 (IOI18_combo)C++14
10 / 100
177 ms768 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include "combo.h"

using namespace std;

string rez(string s, int x){
    string y = "";
    for (int i = 0; i < x; i++)
        y += s[i];
    return y;
}

string maks(string a, string b, string x, string y, string curr){
    if (a.length() > curr.length())
        return a;
    if (b.length() > curr.length())
        return b;
    if (x.length() > curr.length())
        return x;
    return y;
}

string guess_sequence(int n){
    
    string curr = "";
    while(curr.length() < n){
        string a = rez(curr + 'A', press(curr + 'A'));
        string x = rez(curr + 'X', press(curr + 'X'));
        string y = rez(curr + 'Y', press(curr + 'Y'));
        string b = rez(curr + 'B', press(curr + 'B'));
        curr = maks(a, b, x, y, curr);
        if (curr.length() == n)
            return curr;
    }
    return curr;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |     while(curr.length() < n){
      |           ~~~~~~~~~~~~~~^~~
combo.cpp:34:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |         if (curr.length() == n)
      |             ~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...