QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#659497 | #9477. Topological Sort | ucup-team3659# | WA | 1ms | 3532kb | C++20 | 566b | 2024-10-19 20:26:08 | 2024-10-19 20:26:09 |
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)
k=a[i];
else
(ans+=mid-1)%=mid;
cout<<pw(2,ans);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3532kb
input:
3 1 3 2
output:
2
result:
wrong answer 1st words differ - expected: '4', found: '2'