QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#607813 | #9354. Justifying the Conjecture | shmilyc# | WA | 1ms | 3616kb | C++20 | 1.2kb | 2024-10-03 16:31:21 | 2024-10-03 16:31:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int MOD=1e9+7;
#define int long long
#define mp make_pair
#define ll long long
ll modExp(ll base, ll exp, ll mod) {
ll result = 1;
while (exp > 0) {
if (exp % 2 == 1) {
result = (result * base) % mod;
}
base = (base * base) % mod;
exp /= 2;
}
return result;
}
// 计算模逆元
ll modInverse(ll x, ll mod) {
return modExp(x, mod - 2, mod);
}
void solve()
{
int n;
cin>>n;
vector<int> a(n+1);
for(int i=1;i<=n;i++){
cin>>a[i];
}
int ans=1;
int len=0;
if(a[1]!=0||a[n]!=n-1){
cout<<0<<endl;
return;
}
for(int i=1;i<=n;i++){
if(a[i]<a[i-1]||a[i]<i-1){
cout<<0<<endl;
return;
}
if(a[i]+1>len)
ans=(ans*2)%MOD;
else
ans=(ans*(len-i+1))%MOD;
len=a[i]+1;
}
cout<<ans*modInverse(2,MOD)%MOD<<endl;
return;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int T;
cin>>T;
while(T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3616kb
input:
3 4 6 7
output:
0 0 0
result:
wrong answer Integer 0 violates the range [1, 10^9]