Submission #923288

#TimeUsernameProblemLanguageResultExecution timeMemory
923288vjudge1Hidden Sequence (info1cup18_hidden)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; vector<int>findSequence(int n){ map<set<string>,string>cnt; for(int i=0;i<(1<<n);i++){ string s=""; for(int j=0;j<n;j++){ if((i>>j)&1){ s+='1'; }else{ s+='0'; } } set<string>e; for(int r=(n/2+1);r<=(n/2+1);r++){ for(int k=0;k<(1<<(r));k++){ string t=""; for(int j=0;j<(r);j++){ if((k>>j)&1){ t+='1'; }else{ t+='0'; } } int p=0; for(auto u:s){ if(p<t.size() and u==t[p]){ p++; } } if(p==t.size()){ e.insert(t); } } } cnt[e]=s; } set<vector<int>>e; for(int r=(n/2+1);r<=(n/2+1);r++){ for(int k=0;k<(1<<(r));k++){ vector<int>t; for(int j=0;j<(r);j++){ if((k>>j)&1){ t.push_back(1); }else{ t.push_back(0); } } if(isSubsequence(t)){ e.insert(t); } } } vector<int>ans; for(auto u:cnt[e]){ ans.push_back(u-'0'); } return ans; }

Compilation message (stderr)

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:28:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                     if(p<t.size() and u==t[p]){
      |                        ~^~~~~~~~~
hidden.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |                 if(p==t.size()){
      |                    ~^~~~~~~~~~
hidden.cpp:56:19: error: no match for 'operator[]' (operand types are 'std::map<std::set<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >' and 'std::set<std::vector<int> >')
   56 |     for(auto u:cnt[e]){
      |                   ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from hidden.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::set<std::__cxx11::basic_string<char> >; _Tp = std::__cxx11::basic_string<char>; _Compare = std::less<std::set<std::__cxx11::basic_string<char> > >; _Alloc = std::allocator<std::pair<const std::set<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::__cxx11::basic_string<char>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::set<std::__cxx11::basic_string<char> >]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'std::set<std::vector<int> >' to 'const key_type&' {aka 'const std::set<std::__cxx11::basic_string<char> >&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::set<std::__cxx11::basic_string<char> >; _Tp = std::__cxx11::basic_string<char>; _Compare = std::less<std::set<std::__cxx11::basic_string<char> > >; _Alloc = std::allocator<std::pair<const std::set<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::__cxx11::basic_string<char>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::set<std::__cxx11::basic_string<char> >]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'std::set<std::vector<int> >' to 'std::map<std::set<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::key_type&&' {aka 'std::set<std::__cxx11::basic_string<char> >&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
grader.cpp: In function 'int main()':
grader.cpp:28:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   28 |     fprintf (fifo_out, "%d\n", ans.size ());
      |                         ~^     ~~~~~~~~~~~
      |                          |              |
      |                          int            std::vector<int>::size_type {aka long unsigned int}
      |                         %ld
grader.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i=0; i<ans.size () && i < N; i++)
      |                   ~^~~~~~~~~~~~