QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#790579 | #9477. Topological Sort | k1nsom# | TL | 0ms | 0kb | C++20 | 729b | 2024-11-28 13:41:50 | 2024-11-28 13:41:52 |
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