Submission #534438

#TimeUsernameProblemLanguageResultExecution timeMemory
534438MrDebooCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>
// #define int long long
using namespace std;
std::string guess_sequence(int n) {
    srand(time(NULL));
    char f[]={'A','B','X','Y'};
    string s;
    vector<char>ve;
    for(auto &i:f)ve.push_back(i);
    vector<char>v=ve;
    int cnt=0;
    while(s.size()!=n){
        bool bl=0;
        map<char,bool>mp;
        cnt++;
        for(int w=0;w<v.size()-1;w++){
            string G;
            G+=v[w];
            for(int i=0;i<50;i++)G+=ve[rand()%ve.size()];
            int k=press(s+G);
            if(k>s.size()){
                int f=s.size();
                if(k!=G.size()+f)mp[G[k-s.size()]]=1;
                for(int i=0;i<k-f;i++){
                    s+=G[i];
                }
                bl=1;
                break;
            }
        }
        if(!bl)s+=v.back();
        if(cnt==1){
            vector<int>a;
            for(auto i:ve)if(i!=s[0])a.push_back(i);
            ve=a;
        }
        vector<char>V;
        for(auto i:ve)if(!mp[i])V.push_back(i);
        v=V;
    }
    return s;
  // std::string p = "";
  // for (int i = 0; i < 4 * N; ++i) {
  //   p += 'A';
  // }
  // int coins = press(p);
  // std::string S = "";
  // for (int i = 0; i < N; ++i) {
  //   S += 'A';
  // }
  // return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |     while(s.size()!=n){
      |           ~~~~~~~~^~~
combo.cpp:17:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for(int w=0;w<v.size()-1;w++){
      |                     ~^~~~~~~~~~~
combo.cpp:22:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             if(k>s.size()){
      |                ~^~~~~~~~~
combo.cpp:24:21: 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(k!=G.size()+f)mp[G[k-s.size()]]=1;
      |                    ~^~~~~~~~~~~~
combo.cpp:36:16: error: no match for 'operator=' (operand types are 'std::vector<char>' and 'std::vector<int>')
   36 |             ve=a;
      |                ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from combo.cpp:2:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = char; _Alloc = std::allocator<char>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<char>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from combo.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = char; _Alloc = std::allocator<char>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<char>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = char; _Alloc = std::allocator<char>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<char>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~