제출 #850524

#제출 시각아이디문제언어결과실행 시간메모리
850524askow콤보 (IOI18_combo)C++14
0 / 100
0 ms344 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
/*
int N;
string S="ABXYB";
int press(std::string p) {
  int len = p.length();
  if (len > 4 * N) {
    //wrong_answer("invalid press");
  }
  for (int i = 0; i < len; ++i) {
    if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') {
      //wrong_answer("invalid press");
    }
  }
  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 = std::max(coins, j);
  }
  return coins;
}*/
std::string guess_sequence(int N) {
    string pref="";
    if(press("AB")){
        if(press("A"))pref="A";
        else pref="B";
    }
    else {
        if(press("X"))pref="X";
        else pref="Y";
    }
    vector<char>probaj;
    if(pref[0]!='A')probaj.push_back('A');
    if(pref[0]!='B')probaj.push_back('B');
    if(pref[0]!='X')probaj.push_back('X');
    if(pref[0]!='Y')probaj.push_back('Y');
    //for(auto it:probaj)cout<<it<<" ";
    //cout<<endl;
    for(int i=1;i<=N-2;i++){
        string pitam="";
        for(int j=0;j<3;j++){
            pitam+=pref;
            pitam+=probaj[0];
            pitam+=probaj[j];
        }
        pitam+=pref;
        pitam+=probaj[1];
        int x=press(pitam);
        //cout<<x<<" "<<pitam;
        //cout<<endl;
        if(x==pref.size())pref+=probaj[2];
        else if(x==pref.size()+1)pref+=probaj[1];
        else pref+=probaj[2];
    }
    if(N>1){
        if(press(pref+probaj[0]+pref+probaj[1])){
            if(press(pref+probaj[0]))pref+=probaj[0];
            else pref+=probaj[1];
        }
        else pref+=probaj[2];
    }
    return pref;
}/*
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    cout<<guess_sequence(n);
}*/

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:59:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         if(x==pref.size())pref+=probaj[2];
      |            ~^~~~~~~~~~~~~
combo.cpp:60:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         else if(x==pref.size()+1)pref+=probaj[1];
      |                 ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...