Task: | Permutaatio |
Sender: | adex720 |
Submission time: | 2025-01-18 16:58:34 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
#2 | RUNTIME ERROR | 0 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | RUNTIME ERROR | 0.00 s | 1, 2, 3 | details |
#2 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details |
#3 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details |
#4 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details |
#5 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details |
#6 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#7 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#8 | RUNTIME ERROR | 0.00 s | 1, 2, 3 | details |
#9 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#10 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details |
#11 | WRONG ANSWER | 0.00 s | 2, 3 | details |
#12 | WRONG ANSWER | 0.00 s | 2, 3 | details |
#13 | RUNTIME ERROR | 0.00 s | 2, 3 | details |
#14 | ACCEPTED | 0.00 s | 2, 3 | details |
#15 | WRONG ANSWER | 0.00 s | 2, 3 | details |
#16 | WRONG ANSWER | 0.21 s | 3 | details |
#17 | WRONG ANSWER | 0.21 s | 3 | details |
#18 | RUNTIME ERROR | 0.14 s | 3 | details |
#19 | ACCEPTED | 0.19 s | 3 | details |
#20 | WRONG ANSWER | 0.18 s | 3 | details |
#21 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details |
#22 | WRONG ANSWER | 0.01 s | 2, 3 | details |
#23 | WRONG ANSWER | 0.04 s | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:68:13: warning: unused variable 'arvo' [-Wunused-variable] 68 | int arvo = a[i]; | ^~~~
Code
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; int a[n]; int b[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } int suurin = 0; for (int i = 0; i < n; i++) { if (a[i] <= suurin) continue; if (a[i] == suurin + 1) { suurin++; continue; } cout << -1; return 0; } suurin = 0; for (int i = n - 1; i >= 0; i--) { if (b[i] <= suurin) continue; if (b[i] == suurin + 1) { suurin++; continue; } cout << -1; return 0; } queue<int> alut[n]; int olemassa[n]; for (int i = 0; i < n; i++) { olemassa[i] = 0; } int ereja = 0; stack<pair<int, int>> erit; for (int i = 0; i < n; i++) { int arvo = a[i]; if (!olemassa[a[i]]) { erit.push({a[i], i}); ereja++; olemassa[a[i]] = 1; } alut[a[i]].push(i); } priority_queue<pair<int, int>> q; auto eka = erit.top(); int suurinKayttamaton = eka.first; erit.pop(); int id = alut[eka.first].front(); alut[eka.first].pop(); q.push({b[id], id}); int tulos[n]; int seuraava = n; while (!q.empty()) { auto p = q.top(); q.pop(); tulos[p.second] = seuraava; seuraava--; int arvo = a[p.second]; if (!alut[arvo].empty()) { int ind = alut[arvo].front(); alut[arvo].pop(); q.push({b[ind], ind}); } if (arvo == suurinKayttamaton) { if (erit.empty()) { suurinKayttamaton = 0; continue; } auto y = erit.top(); suurinKayttamaton = y.first; erit.pop(); int ind = alut[suurinKayttamaton].front(); alut[suurinKayttamaton].pop(); q.push({b[ind], ind}); } } for (int t : tulos) { cout << t << " "; } }
Test details
Test 1
Group: 1, 2, 3
Verdict: RUNTIME ERROR
input |
---|
1 1 1 |
correct output |
---|
1 |
user output |
---|
(empty) |
Test 2
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
2 1 1 1 1 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
2 1 |
Test 3
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
3 1 1 3 3 2 1 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
-1 |
Test 4
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
3 1 3 2 2 1 3 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
-1 |
Test 5
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
5 1 2 3 4 5 2 1 1 1 1 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
2 3 4 5 3 |
Test 6
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
8 1 2 2 3 2 3 4 5 1 3 2 2 1 1 1 1 |
correct output |
---|
1 8 5 7 2 3 4 6 |
user output |
---|
1 5 4 6 2 3 7 8 |
Test 7
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
8 1 2 2 2 1 3 2 1 3 5 4 3 2 3 2 1 |
correct output |
---|
3 8 6 5 2 7 4 1 |
user output |
---|
4 7 6 5 2 8 3 1 |
Test 8
Group: 1, 2, 3
Verdict: RUNTIME ERROR
input |
---|
8 1 2 3 4 5 6 7 8 1 1 1 1 1 1 1 1 |
correct output |
---|
1 2 3 4 5 6 7 8 |
user output |
---|
(empty) |
Test 9
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
8 1 1 1 1 1 1 1 1 8 7 6 5 4 3 2 1 |
correct output |
---|
8 7 6 5 4 3 2 1 |
user output |
---|
8 7 6 5 4 3 2 1 |
Test 10
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
8 7 6 5 4 3 2 1 |
Test 11
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
500 1 2 2 3 4 4 5 4 6 4 7 8 5 7 9 ... |
correct output |
---|
25 205 54 76 500 218 316 181 3... |
user output |
---|
84 177 160 178 427 362 428 318... Truncated |
Test 12
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
500 1 2 3 1 1 2 2 4 1 3 5 3 3 3 4 ... |
correct output |
---|
336 388 404 309 233 377 240 42... |
user output |
---|
371 379 382 369 356 376 357 38... Truncated |
Test 13
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
500 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
(empty) |
Test 14
Group: 2, 3
Verdict: ACCEPTED
input |
---|
500 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
500 499 498 497 496 495 494 49... |
user output |
---|
500 499 498 497 496 495 494 49... Truncated |
Test 15
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
500 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
IMPOSSIBLE |
user output |
---|
500 499 498 497 496 495 494 49... Truncated |
Test 16
Group: 3
Verdict: WRONG ANSWER
input |
---|
200000 1 2 2 3 2 1 3 3 2 4 2 3 5 4 5 ... |
correct output |
---|
12162 165274 130162 168624 391... |
user output |
---|
43113 183849 179374 183850 989... Truncated |
Test 17
Group: 3
Verdict: WRONG ANSWER
input |
---|
200000 1 1 2 3 3 2 4 3 4 5 2 5 6 7 3 ... |
correct output |
---|
191389 13806 133836 173924 159... |
user output |
---|
182543 47790 182544 188504 188... Truncated |
Test 18
Group: 3
Verdict: RUNTIME ERROR
input |
---|
200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
(empty) |
Test 19
Group: 3
Verdict: ACCEPTED
input |
---|
200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
200000 199999 199998 199997 19... |
user output |
---|
200000 199999 199998 199997 19... Truncated |
Test 20
Group: 3
Verdict: WRONG ANSWER
input |
---|
200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
IMPOSSIBLE |
user output |
---|
200000 199999 199998 199997 19... Truncated |
Test 21
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
8 1 1 2 1 2 3 1 3 4 3 3 2 2 3 1 1 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
-1 |
Test 22
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
500 1 2 3 2 1 2 1 2 3 3 3 3 4 1 5 ... |
correct output |
---|
IMPOSSIBLE |
user output |
---|
-1 |
Test 23
Group: 3
Verdict: WRONG ANSWER
input |
---|
200000 1 1 1 2 2 3 1 3 4 1 5 4 2 5 6 ... |
correct output |
---|
IMPOSSIBLE |
user output |
---|
-1 |