QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#659493#9477. Topological Sortucup-team3659#WA 1ms3668kbC++20538b2024-10-19 20:25:062024-10-19 20:25:08

Judging History

你现在查看的是最新测评结果

  • [2024-10-19 20:25:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3668kb
  • [2024-10-19 20:25:06]
  • 提交

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'