QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#659493 | #9477. Topological Sort | ucup-team3659# | WA | 1ms | 3668kb | C++20 | 538b | 2024-10-19 20:25:06 | 2024-10-19 20:25:08 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[500005];
const int mod=998244353,mid=998244352;
int pw(int a,int b)
{
int ans=1;
while(b)
{
if(b&1)
ans=ans*a%mod;
a=a*a%mod;
b>>=1;
}
return ans;
}
int n;
vector<int> v;
signed main()
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
int ans=n*(n-1)/2%mid;
int k=n+1;
for(int i=1;i<=n;i++)
if(a[i]<k)
(ans+=mid-1)%=mid,k=a[i];
cout<<pw(2,ans);
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3536kb
input:
3 1 3 2
output:
4
result:
ok "4"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3668kb
input:
5 1 2 3 4 5
output:
512
result:
wrong answer 1st words differ - expected: '1024', found: '512'