제출 #1143075

#제출 시각아이디문제언어결과실행 시간메모리
1143075jadai007콤보 (IOI18_combo)C++20
0 / 100
0 ms408 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;
/*
int N;
string S;

int press(string p){
  int len = p.length();
  int coins = 0;
  for (int i = 0, j = 0; i < len; ++i) {
    if (j < N && S[j] == p[i]) {
      ++j;
    } else if (S[0] == p[i]) {
      j = 1;
    } else {
      j = 0;
    }
    coins = max(coins, j);
  }
  return coins;
}
*/

string guess_sequence(int N){
    string ans = "";
    bool back = true;
    while(ans.size() < N){
        if(back){
            string ck1 = ans + 'A';
            string ck2 = ans + 'B';
            string ck3 = ans + 'X';
            string ck4 = ans + 'Y';
            if(press(ck1) == ck1.size()) ans += 'A';
            else if(press(ck2) == ck2.size()) ans += 'B';
            else if(press(ck3) == ck3.size()) ans += 'X';
            else if(press(ck4) == ck4.size()) ans += 'Y';
            else back = false;
        }
        if(!back){
            string ck1 = 'A' + ans;
            string ck2 = 'B' + ans;
            string ck3 = 'X' + ans;
            string ck4 = 'Y' + ans;
            if(press(ck1) == ck1.size()) ans = ck1;
            else if(press(ck2) == ck2.size()) ans = ck2;
            else if(press(ck3) == ck3.size()) ans = ck3;
            else if(press(ck4) == ck4.size()) ans = ck4;
            else back = true;
        }
        return ans;
    }
    
}
/*
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> N >> S;
    guess_sequence(N);
    
}
*/

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...