/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'int main()':
foo.cc:42:23: error: no match for 'operator<' (operand types are 'std::basic_ostream<char>' and 'const char [2]')
   42 |    cout<<min({mx,x,y})<"\n";
      |    ~~~~~~~~~~~~~~~~~~~^~~~~
      |        |               |
      |        |               const char [2]
      |        std::basic_ostream<char>
In file included from /usr/include/c++/11/regex:63,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110,
                 from foo.cc:1:
/usr/include/c++/11/bits/regex.h:1244:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Alloc> auto std::__cxx11::operator<=>(const std::__cxx11::sub_match<_BiIter>&, std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' (reversed)
 1244 |     operator<=>(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/11/bits/regex.h:1244:5: note:   template argument deduction/substitution failed:
foo.cc:42:24: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'const char [2]'
   42 |    cout<<min({mx,x,y})<"\n";
      |                        ^~~~
In file included from /usr/include/c++/11/regex:63,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110,
                 from foo.cc:1:
/usr/include/c++/11/bits/regex.h:1412:5: note: candidate: 'template<class _Bi_iter> auto std::__cxx11::operator<=>(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' (reversed)
 1412 |     operator<=>(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/11/bits/regex.h:1412:5: note:   template argument deduction/substitution failed:
foo.cc:42:24: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'const char [2]'
   42 |    cout<<min({mx,x,y})<"\n";
      |                        ^~~~
In file included from /usr/include/c++/11/regex:63,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110,
                 from foo.cc:1:
/usr/include/c++/11/bits/regex.h:1585:5: note: candidate: 'template<class _Bi_iter> auto std::__cxx11::operator<=>(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' (reversed)
 1585 |     operator<=>(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/11/bits/regex.h:1585:5: note:   template argument deduction/substitution failed:
foo.cc:42:24: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'const char [2]'
   42 |    cout<<min({mx,x,y})<"\n";
      |                        ^~~~
In file included from /usr/include/c++/11/bits/stl_algobase.h:67,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from foo.cc:1:
/usr/include/c++/11/bits/stl_iterator.h:538:5: note: candidate: 'template<class _IteratorL, class _IteratorR>  requires  three_way_comparable_with<_IteratorR, _IteratorL, std::partial_ordering> constexpr std::compare_three_way_result_t<_IteratorL, _IteratorR> std::operator<=>(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)' (reversed)
  538 |     operator<=>(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/11/bits/stl_iterator.h:538:5: note:   template argument deduction/substitution failed:
foo.cc:42:24: note:   mismatched types 'const std::reverse_iterator<_IteratorL>' and 'const char [2]'
   42 |    cout<<min({mx,x,y})<"\n";
      |                        ^~~~
In file included from /usr/include/c++/11/bits/stl_algobase.h:67,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from foo.cc:1:
/usr/include/c++/11/bits/stl_iterator.h:1596:5: note: candidate: 'template<class _IteratorL, class _IteratorR>  requires  three_way_comparable_with<_IteratorR, _IteratorL, std::partial_ordering> constexpr std::compare_three_way_result_t<_IteratorL, _IteratorR> std::operator<=>(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)' (reversed)
 1596 |     operator<=>(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/11/bits/stl_iterator.h:1596:5: note:   template argument deduction/substitution failed:
foo.cc:42:24: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'const char [2]'
   42 |    cout<<min({mx,x,y})<"\n";
      |                        ^~~~
In file included from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=2e5+10,MOD=1000000007;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    cin>>t;
    while(t--){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int x=1;
    int y=1;
    for(int i=1;i<n;i++)x&=(s[i]>=s[i-1]);
    for(int i=1;i<n;i++)y&=(s[i]<=s[i-1]);
    if(x || y){
        cout<<0<<"\n";
        continue;
    }
    vector<int>N(2,0);
    for(int i=0;i<n;i++){
        N[s[i]-'0']++;
    }
   
    for(int i=0;i<N[0];i++){
        x+=(s[i]=='1');
    }
    for(int i=n-1;i>=n-N[0];i--){
        y+=(s[i]=='1');
    }
   int mx=min(x,y);
   x=0,y=0;
   for(int i=0;i<N[1];i++){
    x+=(s[i]=='0');
   }
   for(int i=n-1;i>=n-N[1];i--)y+=(s[i]=='0');
   cout<<min({mx,x,y})<"\n";


     
 }


    
    return 0;
 
}

Information

Submit By
Type
Pretest
Problem
P1016 Swap sort
Language
C++20 (G++ 13.2.0)
Submit At
2024-01-05 16:17:19
Judged At
2024-01-05 16:17:19
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes