QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#572703#9353. Interesting Permutationleo2005WA 0ms3820kbC++14898b2024-09-18 16:01:102024-09-18 16:01:17

Judging History

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

  • [2024-09-18 16:01:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-09-18 16:01:10]
  • 提交

answer

#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
int h[maxn];
typedef long long ll;
int t;
int n;
void solve(){
    ll p,q;
    int flag=1;
    scanf("%lld",&n);
    scanf("%lld",&p);
    ll ans=1,cnt=0;
    if(p!=0){
        flag=0;
    }
    for(int i=0;i<n-1;i++){
        scanf("%lld",&q);
       if(q<p||q>=n){
         flag=0;
       }
       if(q>p){//第一种情况,后面一项比前面一项大
        cnt=(cnt+q-p-1)%mod;
        ans=(ans*2)%mod;
       }else if(p==q){//第二种情况,后面一项和前面一项相等
         ans=(ans*cnt)%mod;
         cnt=(cnt-1)%mod;
       }
       p=q;

    }
    if(flag){
        printf("%lld\n",ans);
    }else{
        printf("0\n");
    }
}
int main(){
   scanf("%d",&t);
   while (t--)
   {
      solve();
   }
   


    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3820kb

input:

3
3
0 2 2
3
0 1 2
3
0 2 3

output:

2

result:

wrong answer 2nd lines differ - expected: '4', found: ''