제출 #135967

#제출 시각아이디문제언어결과실행 시간메모리
135967neki콤보 (IOI18_combo)C++14
91 / 100
59 ms672 KiB
#include "combo.h"
#include <bits/stdc++.h>
#define loop(i, a, b) for(int i=a;i<b;i++)
using namespace std;
vector<string>zn={"A", "B", "X", "Y"};

std::string guess_sequence(int N) {
    int st;
    vector<int> ost;
    loop(i, 0, 4){
        if(press(zn[i])) st=i;
        else ost.push_back(i);
    }
    string ans=zn[st];
    if(N==1) return ans;
    loop(i, 1, N-1){
        string ask=ans+zn[ost[0]]+ans+zn[ost[1]]+zn[ost[0]]+ans+zn[ost[1]]+zn[ost[1]]+ans+zn[ost[1]]+zn[ost[2]];
        int res=press(ask);
        if(res==ans.length()) ans+=zn[ost[2]];
        else if(res==ans.length()+1) ans+=zn[ost[0]];
        else ans+=zn[ost[1]];
    }
    loop(i, 0, 3){
        if(press(ans+zn[ost[i]])==ans.length()+1) return ans+zn[ost[i]];
    }
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:19:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         if(res==ans.length()) ans+=zn[ost[2]];
      |            ~~~^~~~~~~~~~~~~~
combo.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         else if(res==ans.length()+1) ans+=zn[ost[0]];
      |                 ~~~^~~~~~~~~~~~~~~~
combo.cpp:24:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if(press(ans+zn[ost[i]])==ans.length()+1) return ans+zn[ost[i]];
      |            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
combo.cpp:9:17: warning: control reaches end of non-void function [-Wreturn-type]
    9 |     vector<int> ost;
      |                 ^~~
combo.cpp:14:21: warning: 'st' may be used uninitialized in this function [-Wmaybe-uninitialized]
   14 |     string ans=zn[st];
      |                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...