提交记录 4003
| 用户 | 题目 | 状态 | 得分 | 用时 | 内存 | 语言 | 代码长度 |
|---|---|---|---|---|---|---|---|
| zengminghao | noi18b. 【NOI2018】冒泡排序 | Wrong Answer | 8 | 145.128 ms | 1100 KB | C++ | 943 B |
| 提交时间 | 评测时间 |
|---|---|
| 2018-07-18 20:26:21 | 2020-07-31 22:19:15 |
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod=998244353;
void exgcd(ll a,ll b,ll &x,ll &y){
b?(exgcd(b,a%b,y,x),y-=a/b*x):(x=1,y=0);
}
ll Inv(ll a){
ll x=0,y=0;
exgcd(a,mod,x,y);
return(x%mod+mod)%mod;
}
ll Cat(ll n){
ll ans=1;
for (ll i=1;i<=n;i++) {
ans*=4*i-2,ans%=mod;
ans*=Inv(i+1),ans%=mod;
}
return ans;
}
int T,n,a[277777],b[23333];
bool check(){
int tot=0,ans=0;
for (int i=1;i<=n;i++) tot+=abs(i-(b[i]=a[i]));
for (int i=1;i<=n;i++) for (int j=1;j<n;j++)
if (b[j]>b[j+1]) swap(b[j],b[j+1]),ans++;
return ans*2==tot;
}
void baoli(){
int ans=0;
while (next_permutation(a+1,a+n+1)) if (check()) ans++;
printf("%d\n",ans%998244353);
}
int main(){
scanf("%d",&T);
while (T--){
scanf("%d",&n);
for (int i=1;i<=n;i++)
scanf("%d",a+i);
if (n<=9) baoli(); else
{
for (int i=1;i<=n;i++) if (a[i]!=i) return 0;
printf("%lld\n",Cat(n)-1);
}
}
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 14.82 ms | 24 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #2 | 145.128 ms | 24 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #3 | 10.51 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #4 | 7.87 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #5 | 8.26 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #6 | 7.82 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #7 | 7.82 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #8 | 8 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #9 | 7.38 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #10 | 7.84 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #11 | 7.35 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #12 | 9.84 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #13 | 10.98 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #14 | 10.91 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #15 | 12.72 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #16 | 12.71 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #17 | 25.53 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #18 | 28.52 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #19 | 29.85 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #20 | 31.51 us | 20 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #21 | 7.267 ms | 1 MB + 36 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #22 | 7.628 ms | 1 MB + 76 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #23 | 7.704 ms | 1 MB + 76 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #24 | 7.792 ms | 1 MB + 76 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #25 | 7.805 ms | 1 MB + 76 KB | Runtime Error | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-04-17 16:40:20 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠