Submission #645906

#TimeUsernameProblemLanguageResultExecution timeMemory
645906DenkataPassword (RMI18_password)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> //#include "grader.cpp" using namespace std; int i,j,p,d,m,k,sz; //int query(string q); string ans; pair <int,char> cnt[30]; string guess(int n,int s) { sz=0; ///pisheshe i<='z' for(char c='a';c<='z';c++) { if(c-'a'+1>s)break; string f=""; for(i=1;i<=n;i++) f.push_back(c); sz++; cnt[sz]={query(f),c}; } sort(cnt+1,cnt+sz+1); //for(;;); for(i=1;i<=cnt[sz].first;i++) ans.push_back(cnt[sz].second); for(i=sz-1;i>=1;i--) { //cout<<ans<<" ans in the beginning"<<endl; if(cnt[i].first==0)break; int tek=ans.size(); string newans=""; string l="",r=ans; // cout<<l<<" nachalni "<<r<<endl; j=0; int still=cnt[i].first; while(j<tek) { l.push_back(ans[j]); r.erase(0,1); string f=l; for(int g=1;g<=still;g++) f.push_back(cnt[i].second); f=f+r; // cout<<f<<" for a query"<<endl; p=query(f); k=p-l.size(); if(k<still) { for(int g=1;g<=still-k;g++) newans.push_back(cnt[i].second); still=k;///stil-(stil-k) } newans.push_back(ans[j]); j++; } for(int g=1;g<=still;g++) newans.push_back(cnt[i].second); ans=newans; } return ans; }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:19:18: error: 'query' was not declared in this scope
   19 |         cnt[sz]={query(f),c};
      |                  ^~~~~
password.cpp:19:28: error: no match for 'operator=' (operand types are 'std::pair<int, char>' and '<brace-enclosed initializer list>')
   19 |         cnt[sz]={query(f),c};
      |                            ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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 password.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:390:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type) [with _T1 = int; _T2 = char; typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type = const std::pair<int, char>&]'
  390 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:393:41: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::conditional<true, const std::pair<int, char>&, const std::__nonesuch&>::type' {aka 'const std::pair<int, char>&'}
  390 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~    
  391 |   __and_<is_copy_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
  392 |          is_copy_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393 |   const pair&, const __nonesuch&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:401:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type) [with _T1 = int; _T2 = char; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type = std::pair<int, char>&&]'
  401 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:404:31: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::conditional<true, std::pair<int, char>&&, std::__nonesuch&&>::type' {aka 'std::pair<int, char>&&'}
  401 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~
  402 |   __and_<is_move_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403 |          is_move_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  404 |   pair&&, __nonesuch&&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = char]'
  418 |  operator=(const pair<_U1, _U2>& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note:   template argument deduction/substitution failed:
password.cpp:19:28: note:   couldn't deduce template parameter '_U1'
   19 |         cnt[sz]={query(f),c};
      |                            ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 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 password.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:430:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = char]'
  430 |  operator=(pair<_U1, _U2>&& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:430:2: note:   template argument deduction/substitution failed:
password.cpp:19:28: note:   couldn't deduce template parameter '_U1'
   19 |         cnt[sz]={query(f),c};
      |                            ^
password.cpp:44:15: error: 'query' was not declared in this scope
   44 |             p=query(f);
      |               ^~~~~