Submission #1174634

#TimeUsernameProblemLanguageResultExecution timeMemory
1174634browntoadHidden Sequence (info1cup18_hidden)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; #define ll long long // #define int ll #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define REP1(i, n) FOR(i, 1, n+1) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define pii pair<int, int> #define pip pair<int, pii> #define f first #define s second #define pb push_back #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)((x).size()) #ifdef TOAD #define IOS() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #else #define IOS() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #endif // TOAD const ll maxn = 1e3+5; const int iinf = 1e9+5; bool is_sub(string a, string b){ int ptr = 0; REP(i, SZ(b)){ bool fnd = 0; while(ptr < SZ(a)){ if (a[ptr] == b[i]){ fnd = 1; ptr++; break; } ptr++; } if (!fnd) return 0; } return 1; } string conv(int a, int nm){ string ret; REP(i, nm){ if (a & (1<<i)) ret += '1'; else ret += '0'; } return ret; } vector<int> findSequence(int n){ vector<string> puss; REP(i, (1<<n)){ puss.pb(conv(i, n)); } while(SZ(puss) > 1){ int mn = iinf; string ret; REP1(nm, n/2+2){ REP(j, (1<<nm)){ int suc = 0, fal = 0; REP(k, SZ(puss)){ if (is_sub(puss[k], conv(j, nm))) suc++; else fal++; } if (abs(suc-fal) < mn){ mn = abs(suc-fal); ret = conv(j, nm); } } } vector<int> pp; REP(i, SZ(ret)) pp.pb(ret[i] == '1'); bool qret = isSubsequence(pp); vector<int> tmp; REP(k, SZ(puss)){ if (is_sub(puss[k], conv(j, nm)) == qret){ tmp.pb(puss[k]); } } puss = tmp; } vector<int> ret; REP(i, SZ(puss[0])) ret.pb(puss[0][i] == '1'); return ret; //cout<<mn<<endl; //for (auto pp:ret) cout<<pp<<endl; } /* signed main(){ IOS(); int n; cin>>n; } */ /* 2 3 2 4 3 5 7 5 */

Compilation message (stderr)

hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:83:38: error: 'j' was not declared in this scope
   83 |             if (is_sub(puss[k], conv(j, nm)) == qret){
      |                                      ^
hidden.cpp:83:41: error: 'nm' was not declared in this scope; did you mean 'mn'?
   83 |             if (is_sub(puss[k], conv(j, nm)) == qret){
      |                                         ^~
      |                                         mn
hidden.cpp:84:23: error: no matching function for call to 'std::vector<int>::push_back(__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type&)'
   84 |                 tmp.pb(puss[k]);
      |                 ~~~~~~^~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from hidden.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
hidden.cpp:87:16: error: no match for 'operator=' (operand types are 'std::vector<std::__cxx11::basic_string<char> >' and 'std::vector<int>')
   87 |         puss = tmp;
      |                ^~~
In file included from /usr/include/c++/11/vector:72,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from hidden.cpp:1:
/usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<std::__cxx11::basic_string<char> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from hidden.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::__cxx11::basic_string<char> >&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<std::__cxx11::basic_string<char> >'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
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