QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#137734#6343. Bitaro's travelkonstantys#Compile Error//C++143.0kb2023-08-10 17:11:092024-07-04 01:30:22

Judging History

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

  • [2024-07-04 01:30:22]
  • 评测
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 17:11:09]
  • 提交

answer

#include<iostream>
#include<cstdlib>
#include<cstdio>
#define l 524288
using namespace std;
int n,q,tab[200005],a,t[200005][2];
int dp[2*l+5][2];
int pierwszylewo(int a,int x){ //szukamy pierwszego >=x
    a^=l;
    while(true){
        if(a&1){
            if(dp[a^1][0]>=x){
                a^=1;
                break;
            }
        }
        a>>=1;
        if(a==1) return 1;
    }
    //cerr<<"A ";
    while(true){
        if(a&l) return (a^l)+1;
        a<<=1;
        if(dp[a^1][0]>=x) a^=1;
    }
    //cerr<<"B\n";
}
int pierwszyprawo(int a,int x){ //szukamy pierwszego <=x
    if(a!=1){
        a-=2;
        a^=l;
        while(true){
            if(!(a&1)){
                if(dp[a^1][1]<=x){
                    a^=1;
                    break;
                }
            }
            a>>=1;
            if(a==1) return n;
        }
    }else{
        if(dp[1][1]>x) return n;
    }
    while(true){
        if(a&l) return (a^l)+1;
        a<<=1;
        if(dp[a][1]>x) a^=1;
    }

}
long long wyn[200005];
int main(){
    srand(time(NULL));
    ios_base::sync_with_stdio(0);
    cin>>n;
    //n=200000;
    for(int i=1;i<=n;i++){
        cin>>tab[i];
        //tab[i]=i*(1000000000/n);
        //tab[i]=tab[i-1]+1+rand()%(1000000000-(n-i)-tab[i-1]);
        //cerr<<tab[i]<<"\n";
    }
    tab[0]=-1000000001;
    tab[n+1]=2000000001;
    t[1][0]=n;
    t[n][1]=1;
    dp[1+l-1][0]=t[1][0];
    dp[n+l-1][1]=t[n][1];
    for(int i=2;i<=n;i++){
        t[i][0]=i;
        while(tab[t[i][0]+1]-tab[i]<tab[i]-tab[i-1]) t[i][0]++;
        dp[i+l-1][0]=t[i][0];
    }
    for(int i=n-1;i>=1;i--){
        t[i][1]=i;
        while(tab[i]-tab[t[i][1]-1]<=tab[i+1]-tab[i]) t[i][1]--;
        dp[i+l-1][1]=t[i][1];
    }
    cin>>q;
    for(int i=0;i<q;i++){
        cin<<a;
        cout<<"0\n";
    }
    return 0;
    for(int i=n+1;i<=l;i++) dp[i+l-1][1]=1000000;
    for(int i=l-1;i>=1;i--){
        dp[i][0]=max(dp[i<<1][0],dp[(i<<1)^1][0]);
        dp[i][1]=min(dp[i<<1][1],dp[(i<<1)^1][1]);
    }
    for(int i=1;i<=n;i++){
        int p=i,k=i,s;
        wyn[i]=0;
        while(true){
            s=pierwszylewo(p,k+1);
            wyn[i]+=tab[p]-tab[s];
            if(k==n)
                break;
            k++;
            p=s;
            wyn[i]+=tab[k]-tab[s];

            s=pierwszyprawo(k,p-1);
            wyn[i]+=tab[s]-tab[k];
            if(p==1)
                break;
            p--;
            k=s;
            wyn[i]+=tab[s]-tab[p];
        }
        //cerr<<wyn[i]<<" ";
    }
    q=200000;
    for(int i=0;i<q;i++){
        //cin>>a;
        a=rand()%1000000001;
        //a-=off;
        int p=1,k=n,s,y=n+1;
        while(k>=p){
            s=(p+k)>>1;
            if(tab[s]>=a){
                k=s-1;
                y=s;
            }else p=s+1;
        }
        if(tab[y]-a<a-tab[y-1]){
            cout<<wyn[y]+tab[y]-a<<"\n";
        }else cout<<wyn[y-1]+a-tab[y-1]<<"\n";
    }
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:82:12: error: no match for ‘operator<<’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘int’)
   82 |         cin<<a;
      |         ~~~^~~
      |         |    |
      |         |    int
      |         std::istream {aka std::basic_istream<char>}
answer.code:82:12: note: candidate: ‘operator<<(int, int)’ (built-in)
   82 |         cin<<a;
      |         ~~~^~~
answer.code:82:12: note:   no known conversion for argument 1 from ‘std::istream’ {aka ‘std::basic_istream<char>’} to ‘int’
In file included from /usr/include/c++/13/string:54,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:1:
/usr/include/c++/13/bits/basic_string.h:4020:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’
 4020 |     operator<<(basic_ostream<_CharT, _Traits>& __os,
      |     ^~~~~~~~
/usr/include/c++/13/bits/basic_string.h:4020:5: note:   template argument deduction/substitution failed:
answer.code:82:14: note:   ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘std::basic_ostream<_CharT, _Traits>’
   82 |         cin<<a;
      |              ^
In file included from /usr/include/c++/13/bits/ios_base.h:46:
/usr/include/c++/13/system_error:339:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)’
  339 |     operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
      |     ^~~~~~~~
/usr/include/c++/13/system_error:339:5: note:   template argument deduction/substitution failed:
answer.code:82:14: note:   ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘std::basic_ostream<_CharT, _Traits>’
   82 |         cin<<a;
      |              ^
/usr/include/c++/13/ostream:554:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)’
  554 |     operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
      |     ^~~~~~~~
/usr/include/c++/13/ostream:554:5: note:   template argument deduction/substitution failed:
answer.code:82:14: note:   ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘std::basic_ostream<_CharT, _Traits>’
   82 |         cin<<a;
      |              ^
/usr/include/c++/13/ostream:564:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)’
  564 |     operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
      |     ^~~~~~~~
/usr/include/c++/13/ostream:564:5: note:   template argument deduction/substitution failed:
answer.code:82:14: note:   ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘std::basic_ostream<_CharT, _Traits>’
   82 |         cin<<a;
      |              ^
/usr/include/c++/13/ostream:570:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)’
  570 |     operator<<(basic_ostream<char, _Traits>& __out, char __c)
      |     ^~~~~~~~
/usr/include/c++/13/ostream:570:5: note:   template argument deduction/substitution failed:
answer.code:82:14: note:   ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘std::basic_ostream<char, _Traits>’
   82 |         cin<<a;
      |              ^
/usr/include/c++/13/ostream:581:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)’
  581 |     operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
      |     ^~~~~~~~
/usr/include/c++/13/ostream:581:5: note:   template argument deduction/substitution failed:
answer.code:82:14: note:   ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘std::basic_ostream<char, _Traits>’
   82 |         cin<<a;
      |              ^
/usr/include/c++/13/ostream:586:5: note: candidate: ‘template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)’
  586 |     operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
      |     ^~~~~~~~
/usr/include/c++/13/ostream:586:5: note:   template argument deduction/substitution failed:
answer.code:82:14: note:   ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘std::basic_ostream<char, _Traits>’
   82 |         cin<<a;
      |              ^
/usr/include/c++/13/ostream:645:5: note: candidate: ‘template<class ...