QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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);
}
Details
Tip: Click on the bar to expand more detailed information
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'