QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572692#9353. Interesting Permutationleo2005WA 0ms3832kbC++14888b2024-09-18 15:58:352024-09-18 15:58:35

Judging History

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

  • [2024-09-18 15:58:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3832kb
  • [2024-09-18 15:58:35]
  • 提交

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(){
   cin>>t;
   while (t--)
   {
      solve();
   }
   


    return 0;
}

详细

Test #1:

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

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: ''