QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#799387#8050. Random Permutationgyydp123_LIMWA 783ms6312kbC++141.2kb2024-12-05 12:42:512024-12-05 12:42:52

Judging History

This is the latest submission verdict.

  • [2024-12-05 12:42:52]
  • Judged
  • Verdict: WA
  • Time: 783ms
  • Memory: 6312kb
  • [2024-12-05 12:42:51]
  • Submitted

answer

#include<bits/stdc++.h>
#define For(i,j,k) for(int i=(j);i<=(k);++i)
#define ForDown(i,j,k) for(int i=(j);i>=(k);--i)
#define Debug(fmt, args...) fprintf(stderr,"(func %s, line #%d): " fmt,__func__,__LINE__,##args),fflush(stderr)
#define debug(fmt, args...) fprintf(stderr,fmt,##args),fflush(stderr)
#define within :
#define LJY main
using namespace std;
typedef long long ll;
const int N=3e5+5,B=1000;
inline int read(){
  char ch=getchar();int x=0,f=1;
  while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
  while(ch>='0'&&ch<='9')
    x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
  return x*f;
}
int n,p[N],pos[N],a[N];
int sum[N],cnt1[B<<1],cnt2[B<<1];
signed LJY(){
  n=read();For(i,1,n) pos[p[i]=read()]=i;
  ll ans=0;For(i,1,n) a[i]=-1;
  ForDown(i,n,1){
    memset(cnt1,0,sizeof(cnt1));
    memset(cnt2,0,sizeof(cnt2));
    cnt1[B]=cnt2[B]=1;int s=B;
    For(j,pos[i]+1,n){
      s+=a[j];
      if(s<0||s>=(B<<1)) break;
      cnt1[s]++;
    }s=B;
    ForDown(j,pos[i]-1,1){
      s+=a[j];
      if(s<0||s>=(B<<1)) break;
      cnt2[s]++;
    }a[pos[i]]=1;
    ll tot=0;
    For(i,1,(B<<1)-1) tot+=(ll)cnt1[i]*(cnt2[(B<<1)-i]+cnt2[(B<<1)-i+1]);
    ans+=tot*i;
  }printf("%lld",ans);
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5932kb

input:

4
1 4 2 3

output:

22

result:

ok 1 number(s): "22"

Test #2:

score: -100
Wrong Answer
time: 783ms
memory: 6312kb

input:

100000
56449 21738 74917 44834 36187 96576 37204 28451 3444 13029 66039 8955 51445 30706 27229 37159 66052 16691 70389 29935 44984 3648 75082 73600 76621 28345 5298 37940 49412 85260 92029 18185 84398 10233 79227 98312 96649 30680 65206 38879 75397 26951 11294 58085 37297 97167 59252 44104 4058 3796...

output:

250214248190569

result:

wrong answer 1st numbers differ - expected: '250202478701074', found: '250214248190569'