Submission #346442

#TimeUsernameProblemLanguageResultExecution timeMemory
346442lebasivillarCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#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 (int 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 (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for (int i = 0; i<sequence.size(); i++){
      |                   ~^~~~~~~~~~~~~~~~
combo.cpp:36:35: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   36 |       word.push_back(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){
      |          ~~~~~~~~^~~~~