Submission #133401

#TimeUsernameProblemLanguageResultExecution timeMemory
133401redaCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std ; string guess_sequence(int N) { if(N==3) { string ans=""; string use="ABXY"; int g=-1; char t; for(int i=0;i<use.size();i++) { if(press(use[i])>g) { g=press(use[i]); t=use[i]; } } ans+=t; string s=""; for(int i=0;i<use.size();i++) { if(use[i]==t)continue; s+=use[i]; } int i=0,pv=press(ans); while (ans.size()!=3) { string p=ans; p+=s[i]; int k =press(p); if(k>prev) { ans+=s[i]; } else i++; i=i%3; } return ans; } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         for(int i=0;i<use.size();i++)
      |                     ~^~~~~~~~~~~
combo.cpp:15:28: error: could not convert 'use.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   15 |             if(press(use[i])>g)
      |                            ^
      |                            |
      |                            __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
combo.cpp:17:31: error: could not convert 'use.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   17 |                 g=press(use[i]);
      |                               ^
      |                               |
      |                               __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
combo.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(int i=0;i<use.size();i++)
      |                     ~^~~~~~~~~~~
combo.cpp:34:17: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator>'
   34 |             if(k>prev)
      |                ~^~~~~
combo.cpp:28:17: warning: unused variable 'pv' [-Wunused-variable]
   28 |         int i=0,pv=press(ans);
      |                 ^~
combo.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^