답안 #430158

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
430158 2021-06-16T11:46:02 Z oscar1f 최후의 만찬 (IOI12_supper) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "advisor.h"
 
using namespace std;
 
const int NB_BITS=13,MAX_COUL=100*1000,INFINI=1000*1000*1000;
set<int> date[MAX_COUL];
int pres[MAX_COUL];
set<pair<int,int>> proch;
set<int>::iterator it;
set<pair<int,int>>::iterator it2;
 
void crypte(int nb) {
  cout<<nb<<endl;
  for (int i=0;i<NB_BITS;i++) {
    WriteAdvice(char(int('0')+nb%2));
    //cout<<char(int('0')+nb%2)<<" ";
    nb/=2;
  }
}
 
void ComputeAdvice(int *ajout, int nbCoul, int taille, int tailleMax) {
  for (int i=0;i<nbCoul;i++) {
    date[i].insert(INFINI);
  }
  for (int i=0;i<nbCoul;i++) {
    date[ajout[i]].insert(i);
  }
  for (int i=0;i<taille;i++) {
    it=date[i].begin();
    proch.insert(make_pair(*it,i));
    pres[i]=1;
  }
  for (int i=0;i<nbCoul;i++) {
    if (pres[ajout[i]]==1) {
      crypte(nbCoul);
      proch.erase(make_pair(i,ajout[i]));
      it=date[ajout[i]].lower_bound(i+1);
      proch.insert(make_pair(*it,ajout[i]));
    }
    else {
      it2=proch.lower_bound(make_pair(INFINI,INFINI));
      it2--;
      crypte((*it2).second);
      pres[(*it2).second]=0;
      proch.erase(*it2);
      it=date[ajout[i]].lower_bound(i+1);
      pres[ajout[i]]=1;
      proch.insert(make_pair(*it,ajout[i]));
    }
  }
}
#include<bits/stdc++.h>
#include "assistant.h"
using namespace std;
 
const int NB_BITS=13;
string ligne;
 
int decrypte(int pos) {
  int rep=0,multi=1;
  for (int i=NB_BITS*pos;i<NB_BITS*(pos+1);i++) {
    rep+=multi*(int(ligne[i])-int('0'));
    multi*=2;
  }
  return rep;
}
 
void Assist(unsigned char *AA, int NN, int KK, int RR) {
  ligne=AA;
  int nb;
  for (int i=0;i<NN;i++) {
    nb=decrypte(i);
    cout<<nb<<endl;
    nb=GetRequest();
    nb=decrypte(i);
    if (nb!=NN) {
      PutBack(nb);
    }
  }
}

Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:18:9: error: no match for 'operator=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'unsigned char*')
   18 |   ligne=AA;
      |         ^~
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from assistant.cpp:1:
/usr/include/c++/10/bits/basic_string.h:675:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' (near match)
  675 |       operator=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:675:7: note:   conversion of argument 1 would be ill-formed:
assistant.cpp:18:9: error: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive]
   18 |   ligne=AA;
      |         ^~
      |         |
      |         unsigned char*
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from assistant.cpp:1:
/usr/include/c++/10/bits/basic_string.h:686:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' (near match)
  686 |       operator=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:686:7: note:   conversion of argument 1 would be ill-formed:
assistant.cpp:18:9: error: invalid conversion from 'unsigned char*' to 'char' [-fpermissive]
   18 |   ligne=AA;
      |         ^~
      |         |
      |         unsigned char*
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from assistant.cpp:1:
/usr/include/c++/10/bits/basic_string.h:665:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  665 |       operator=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:665:37: note:   no known conversion for argument 1 from 'unsigned char*' to 'const std::__cxx11::basic_string<char>&'
  665 |       operator=(const basic_string& __str)
      |                 ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:703:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  703 |       operator=(basic_string&& __str)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:703:32: note:   no known conversion for argument 1 from 'unsigned char*' to 'std::__cxx11::basic_string<char>&&'
  703 |       operator=(basic_string&& __str)
      |                 ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:766:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  766 |       operator=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:766:42: note:   no known conversion for argument 1 from 'unsigned char*' to 'std::initializer_list<char>'
  766 |       operator=(initializer_list<_CharT> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:780:8: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _Tp&) [with _Tp = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  780 |        operator=(const _Tp& __svt)
      |        ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:780:8: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from assistant.cpp:1:
/usr/include/c++/10/type_traits: In substitution of 'template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]':
/usr/include/c++/10/bits/basic_string.h:117:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using _If_sv = std::enable_if_t<std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value, _Res> [with _Tp = unsigned char*; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
/usr/include/c++/10/bits/basic_string.h:780:8:   required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::operator=<_Tp>(const _Tp&) [with _Tp = unsigned char*]'
assistant.cpp:18:9:   required from here
/usr/include/c++/10/type_traits:2554:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>'
 2554 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~