QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#370480#5045. Kingzzuqy#Compile Error//C++112.2kb2024-03-29 09:21:412024-03-29 09:21:43

Judging History

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

  • [2024-03-29 09:21:43]
  • 评测
  • [2024-03-29 09:21:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long read()
{
    long long x;scanf("%lld",&x);return x;
}
ll quick(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=ans*a%mod;
        b=b/2;
        a=a*a%mod;
    }
    return ans;
}
ll a[200010],n,p;
map<int,int>id;//表示
vector<int>pos[200010];
int ask1()
{
    int x=1ll*rand()*rand()%n+1;
    while(x==n)
        x=1ll*rand()*rand()%n+1;
    int y=min(n,x+1);
    int q=a[y]*quick(a[x],p-2,p);//
    int qq=quick(q,p-2,p);
    int len=2;
    while(x!=1)//往前跳
    {
        ll v=id[a[x]*qq%p];
        if(v==0||pos[v][0]>=x)
            break;
        len++;
        x=*(lower_bound(pos[v].begin(),pos[v].end(),x)-1);

    }
    while(y!=n)
    {
        ll v=id[a[y]*qq%p];
        if(v==0||pos[v].back()<=y)
            break;
        len++;
        y=*upper_bound(pos[v].begin(),pos[v].end(),y);
    }
    return len;
}
int ask1()
{
    int x=1ll*rand()*rand()%n+1;
    while(x==n)
        x=1ll*rand()*rand()%n+1;
    int y=min(n,x+2);
    int q=a[y]*quick(a[x],p-2,p);//
    int qq=quick(q,p-2,p);
    int len=2;
    while(x!=1)//往前跳
    {
        ll v=id[a[x]*qq%p];
        if(v==0||pos[v][0]>=x)
            break;
        len++;
        x=*(lower_bound(pos[v].begin(),pos[v].end(),x)-1);

    }
    while(y!=n)
    {
        ll v=id[a[y]*qq%p];
        if(v==0||pos[v].back()<=y)
            break;
        len++;
        y=*upper_bound(pos[v].begin(),pos[v].end(),y);
    }
    return len;
}
void work()
{
    n=read();p=read();
    id.clear();
    int sum=0;
    for(int i=1;i<=n;i++){
        a[i]=read();
        pos[i].clear();
    }
    for(int i=1;i<=n;i++)
    {
        if(id[a[i]]==0)
        {
            id[a[i]]=++sum;
            pos[sum].push_back(i);
        }
    }
    int ans=-1;
    for(int i=1;i<=1000&&ans*2<n;i++)
    {
        ans=max(ans,ask1()),ans=max(ans,ask2());
    }
    if(ans*2<n)
        ans=-1;
    cout<<ans<<'\n';
}
int main()
{
    srand(time(0));
    for(int t=read();t;t--)
        work();
}




// a[i]
// 下一个数是a[i+1]
// 随机一个五以内的

Details

answer.code: In function ‘int ask1()’:
answer.code:28:14: error: no matching function for call to ‘min(ll&, int)’
   28 |     int y=min(n,x+1);
      |           ~~~^~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:28:14: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   28 |     int y=min(n,x+1);
      |           ~~~^~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:28:14: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   28 |     int y=min(n,x+1);
      |           ~~~^~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> _Tp std::min(initializer_list<_Tp>)’
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
answer.code:28:14: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   28 |     int y=min(n,x+1);
      |           ~~~^~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> _Tp std::min(initializer_list<_Tp>, _Compare)’
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
answer.code:28:14: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   28 |     int y=min(n,x+1);
      |           ~~~^~~~~~~
answer.code: At global scope:
answer.code:51:5: error: redefinition of ‘int ask1()’
   51 | int ask1()
      |     ^~~~
answer.code:23:5: note: ‘int ask1()’ previously defined here
   23 | int ask1()
      |     ^~~~
answer.code: In function ‘int ask1()’:
answer.code:56:14: error: no matching function for call to ‘min(ll&, int)’
   56 |     int y=min(n,x+2);
      |           ~~~^~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:56:14: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   56 |     int y=min(n,x+2);
      |           ~~~^~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:56:14: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   56 |     int y=min(n,x+2);
      |           ~~~^~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> _Tp std::min(initializer_list<_Tp>)’
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
answer.code:56:14: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   56 |     int y=min(n,x+2);
      |           ~~~^~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> _Tp std::min(initializer_list<_Tp>, _Compare)’
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
answer.code:56:14: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   56 |     int y=min(n,x+2);
      |           ~~~^~~~~~~
answer.code: In function ‘void work()’:
answer.code:99:41: error: ‘ask2’ was not declared in this scope; did you mean ‘ask1’?
   99 |         ans=max(ans,ask1()),ans=max(ans,ask2());
      |                                         ^~~~
      |                                         ask1
answer.code: In function ‘long long int read()’:
answer.code:6:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_re...