답안 #346441

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
346441 2021-01-09T17:53:16 Z lebasivillar 콤보 (IOI18_combo) C++14
컴파일 오류
0 ms 0 KB
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include "combo.h"
using namespace std;

string guess_sequence(int N){
  string t;
  if (press("AB")>0){
    if (press("A")>0){
      t.push_back('A');
    }
    else{
      t.push_back('B');
    }
  }
  else{
    if(press("X")>0){
      t.push_back('X');
    }
    else{
      t.push_back('Y');
    }
  }
  
  if (N==1){
    return t;
  }
  string sequence = "ABXY";
  vector <string> left;
  for (in i = 0; i<sequence.size(); i++){
    if(sequence[i] != t[0]){
      string word;
      word.push_back(sequence.size[i]);
      left.push_back(word);
    }
  }
  vector <string> ends = {left[i], left[2] + left[0], left[2] + left[1], left[2]};
  while (t.size()< N-1){
    int value = press(t+ends[0]+t+ends[1]+t+ends[2]+t+ends[3])-t.size();
    if (value==0){
      t += left[0];
    }
    if (value==1){
      t += left[1];
    }
    if (value==2){
      t += left[2];
    }
  }
  if (press(t+left[0])==N){
    t += left[0];
  }
  else if (press(t+left[1])==N){
    t += left[1];
  }
  else{
    t += left[2];
  }
  return t;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:8: error: 'in' was not declared in this scope; did you mean 'int'?
   33 |   for (in i = 0; i<sequence.size(); i++){
      |        ^~
      |        int
combo.cpp:33:18: error: 'i' was not declared in this scope
   33 |   for (in i = 0; i<sequence.size(); i++){
      |                  ^
combo.cpp:40:32: error: 'i' was not declared in this scope
   40 |   vector <string> ends = {left[i], left[2] + left[0], left[2] + left[1], left[2]};
      |                                ^
combo.cpp:40:81: error: could not convert '{<expression error>, std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]((*(const std::__cxx11::basic_string<char>*)(& left.std::vector<std::__cxx11::basic_string<char> >::operator[](0)))), std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]((*(const std::__cxx11::basic_string<char>*)(& left.std::vector<std::__cxx11::basic_string<char> >::operator[](1)))), left.std::vector<std::__cxx11::basic_string<char> >::operator[](2)}' from '<brace-enclosed initializer list>' to 'std::vector<std::__cxx11::basic_string<char> >'
   40 |   vector <string> ends = {left[i], left[2] + left[0], left[2] + left[1], left[2]};
      |                                                                                 ^
      |                                                                                 |
      |                                                                                 <brace-enclosed initializer list>
combo.cpp:41:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |   while (t.size()< N-1){
      |          ~~~~~~~~^~~~~