제출 #696449

#제출 시각아이디문제언어결과실행 시간메모리
696449Elvin_Fritl콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "combo.h" using namespace std; string guess_sequence(int n) { string p = ""; string s="ABXY"; for(int i=0;i<3;i++){ string p1=s[i]; if(press(p1)==1){ p=p1; break; } } if(p.size()==i){ p+=s[3]; } string s2=""; for(int i=0;i<3;i++){ if(p[0]!=s[i]){ s2+=s[i]; } } s=s2; for(int i=1;i<n;i++){ for(int j=0;j<2;j++){ string p1=p+s[j]; if(press(p1)==p1.size()){ p=p1; break; } } if(p.size()==i){ p+=s[2]; } } return p; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:7:22: error: conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
    7 |         string p1=s[i];
      |                      ^
combo.cpp:13:18: error: 'i' was not declared in this scope
   13 |     if(p.size()==i){
      |                  ^
combo.cpp:26:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if(press(p1)==p1.size()){
      |            ~~~~~~~~~^~~~~~~~~~~
combo.cpp:31:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     if(p.size()==i){
      |        ~~~~~~~~^~~