QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#790579#9477. Topological Sortk1nsom#TL 0ms0kbC++20729b2024-11-28 13:41:502024-11-28 13:41:52

Judging History

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

  • [2024-11-28 13:41:52]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-28 13:41:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N = 3e5 + 5;
const int mod = 998244353;
int n, a[N];
int kpow(int n, int k)
{
    int ret = 1;
    while (k)
    {
        if (k & 1)
            (ret *= n) %= mod;
        (n *= n) %= mod, k >> 1;
    }
    return ret;
}
void solve()
{
    cin >> n;
    int mx = 0, cnt = n * (n - 1) / 2;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (mx > a[i])
            cnt--;
        mx = max(mx, a[i]);
    }
    cout << kpow(2, cnt) << endl;
}
signed main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3
1 3 2

output:


result: