QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#658567 | #9477. Topological Sort | ucup-team3691# | WA | 0ms | 3700kb | C++20 | 1008b | 2024-10-19 17:03:37 | 2024-10-19 17:03:42 |
Judging History
answer
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <random>
#include <ctime>
#include <cstdlib>
#include <chrono>
using namespace std;
using ll = long long;
const int mod = 998244353;
int lgput(int x, ll p) {
if (p == 0) {
return 1;
}
if (p % 2 == 0) {
int aux = lgput(x, p/2);
return 1LL * aux * aux % mod;
}
if (p % 2 == 1) {
int aux = lgput(x, p - 1);
return 1LL * aux * x % mod;
}
}
void solve() {
int n, last = 0;
cin >> n;
ll cnt = 1LL * n * (n - 1) / 2;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (last > x) {
cnt--;
}
last = x;
}
cout << lgput(2, cnt) << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
3 1 3 2
output:
4
result:
ok "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
5 1 2 3 4 5
output:
1024
result:
ok "1024"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
6 4 2 1 5 6 3
output:
4096
result:
ok "4096"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3700kb
input:
492 397 486 227 395 58 452 172 216 130 181 268 482 85 209 365 104 373 90 260 326 252 96 267 106 102 398 441 41 292 314 12 78 242 353 153 424 179 86 299 228 54 390 73 465 396 349 4 10 451 99 342 250 391 6 323 197 159 47 136 473 392 77 125 362 418 255 291 13 238 339 8 28 413 121 384 157 152 23 221 305...
output:
692497022
result:
wrong answer 1st words differ - expected: '73428942', found: '692497022'