QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#275498#7880. Streak Manipulationpengpeng_fudan#Compile Error//C++201.5kb2023-12-04 19:36:112023-12-04 19:36:12

Judging History

你现在查看的是最新测评结果

  • [2023-12-04 19:36:12]
  • 评测
  • [2023-12-04 19:36:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int inf=1e8+7;
const int N=2e5+5;
const int K=7;
int n,m,k;
char s[N];
int dp[N][K],minn[N][K];
int cnt[N][2],pre[N];
int check(int mid){
    for(int i=0;i<=n;i++)
        for(int j=0;j<=k;j++){
            dp[i][j]=inf;
            minn[i][j]=inf;
        }
    for(int i=0;i<=n;i++) dp[i][0]=minn[i][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(i>=mid){
                dp[i][j]=cnt[i][0]-cnt[i-mid][0]+minn[pre[i-mid]][j-1];
            }
            minn[i][j]=min(dp[i][j],minn[i-1][j]);
        }
    }
    int ans=inf;
    for(int i=1;i<=n;i++) ans=min(ans,dp[i][k]);
    return ans<=m;
}
int binary(){
    int l=1,r=n,mid;
    int ans=-1;
    while(l<=r){
        mid=(l+r)>>1;
        if(check(mid)){
            l=mid+1;
            ans=mid;
        }else r=mid-1;
    }
    return ans;
}
void solve(){
    cin>>n>>m>>k;
    cin>>s+1;
    for(int i=1;i<=n;i++){
        int d=s[i]-'0';
        cnt[i][d]++;
        if(d==1) pre[i]=i;
        if(s[i]=='0') continue;
        if(i>1&&s[i-1]=='1') pre[i]=pre[i-1];
    }
    for(int i=2;i<=n;i++){
        cnt[i][0]+=cnt[i-1][0];
        cnt[i][1]+=cnt[i-1][1];
        if(pre[i]==0) pre[i]=i;
        else pre[i]=pre[i]-1;
    }
    int ans=binary();
    cout<<ans<<"\n";
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int _=1;
    // cin>>_;
    while(_--)  solve();
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:44:8: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   44 |     cin>>s+1;
      |     ~~~^~~~~
      |     |     |
      |     |     char*
      |     std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:168:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  168 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:168:7: note:   conversion of argument 1 would be ill-formed:
answer.code:44:11: error: cannot bind non-const lvalue reference of type ‘bool&’ to a value of type ‘char*’
   44 |     cin>>s+1;
      |          ~^~
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:172:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  172 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:172:7: note:   conversion of argument 1 would be ill-formed:
answer.code:44:11: error: invalid conversion from ‘char*’ to ‘short int’ [-fpermissive]
   44 |     cin>>s+1;
      |          ~^~
      |           |
      |           char*
answer.code:44:11: error: cannot bind rvalue ‘(short int)(((char*)(& s)) + 1)’ to ‘short int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:175:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  175 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:175:7: note:   conversion of argument 1 would be ill-formed:
answer.code:44:11: error: invalid conversion from ‘char*’ to ‘short unsigned int’ [-fpermissive]
   44 |     cin>>s+1;
      |          ~^~
      |           |
      |           char*
answer.code:44:11: error: cannot bind rvalue ‘(short unsigned int)(((char*)(& s)) + 1)’ to ‘short unsigned int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:179:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  179 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:179:7: note:   conversion of argument 1 would be ill-formed:
answer.code:44:11: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive]
   44 |     cin>>s+1;
      |          ~^~
      |           |
      |           char*
answer.code:44:11: error: cannot bind rvalue ‘(int)(((char*)(& s)) + 1)’ to ‘int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:182:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  182 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:182:7: note:   conversion of argument 1 would be ill-formed:
answer.code:44:11: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive]
   44 |     cin>>s+1;
      |          ~^~
      |           |
      |           char*
answer.c...