Task: | Optimal sort |
Sender: | htoik |
Submission time: | 2024-10-28 17:44:05 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | WRONG ANSWER | 0.00 s | details |
#3 | WRONG ANSWER | 0.00 s | details |
#4 | WRONG ANSWER | 0.00 s | details |
#5 | WRONG ANSWER | 0.00 s | details |
#6 | WRONG ANSWER | 0.00 s | details |
#7 | WRONG ANSWER | 0.00 s | details |
#8 | WRONG ANSWER | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | WRONG ANSWER | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | WRONG ANSWER | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | WRONG ANSWER | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | WRONG ANSWER | 0.00 s | details |
#19 | WRONG ANSWER | 0.00 s | details |
#20 | WRONG ANSWER | 0.00 s | details |
#21 | ACCEPTED | 0.00 s | details |
#22 | WRONG ANSWER | 0.00 s | details |
#23 | WRONG ANSWER | 0.00 s | details |
#24 | WRONG ANSWER | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | WRONG ANSWER | 0.00 s | details |
#27 | WRONG ANSWER | 0.00 s | details |
#28 | ACCEPTED | 0.00 s | details |
#29 | WRONG ANSWER | 0.00 s | details |
#30 | WRONG ANSWER | 0.00 s | details |
#31 | RUNTIME ERROR | 0.00 s | details |
#32 | RUNTIME ERROR | 0.00 s | details |
#33 | RUNTIME ERROR | 0.00 s | details |
#34 | RUNTIME ERROR | 0.00 s | details |
#35 | RUNTIME ERROR | 0.00 s | details |
#36 | RUNTIME ERROR | 0.00 s | details |
#37 | RUNTIME ERROR | 0.00 s | details |
#38 | RUNTIME ERROR | 0.00 s | details |
#39 | RUNTIME ERROR | 0.00 s | details |
#40 | RUNTIME ERROR | 0.00 s | details |
#41 | RUNTIME ERROR | 0.00 s | details |
#42 | RUNTIME ERROR | 0.00 s | details |
#43 | RUNTIME ERROR | 0.00 s | details |
#44 | RUNTIME ERROR | 0.00 s | details |
#45 | RUNTIME ERROR | 0.00 s | details |
#46 | RUNTIME ERROR | 0.00 s | details |
#47 | RUNTIME ERROR | 0.00 s | details |
#48 | RUNTIME ERROR | 0.00 s | details |
#49 | RUNTIME ERROR | 0.00 s | details |
#50 | RUNTIME ERROR | 0.00 s | details |
#51 | RUNTIME ERROR | 0.00 s | details |
#52 | RUNTIME ERROR | 0.01 s | details |
#53 | RUNTIME ERROR | 0.00 s | details |
#54 | RUNTIME ERROR | 0.00 s | details |
#55 | RUNTIME ERROR | 0.00 s | details |
#56 | RUNTIME ERROR | 0.00 s | details |
#57 | RUNTIME ERROR | 0.00 s | details |
#58 | RUNTIME ERROR | 0.00 s | details |
#59 | RUNTIME ERROR | 0.00 s | details |
#60 | RUNTIME ERROR | 0.00 s | details |
#61 | TIME LIMIT EXCEEDED | -- | details |
#62 | TIME LIMIT EXCEEDED | -- | details |
#63 | TIME LIMIT EXCEEDED | -- | details |
#64 | TIME LIMIT EXCEEDED | -- | details |
#65 | TIME LIMIT EXCEEDED | -- | details |
#66 | TIME LIMIT EXCEEDED | -- | details |
#67 | TIME LIMIT EXCEEDED | -- | details |
#68 | TIME LIMIT EXCEEDED | -- | details |
#69 | TIME LIMIT EXCEEDED | -- | details |
#70 | TIME LIMIT EXCEEDED | -- | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'ull' {aka 'long long unsigned int'} [-Wsign-compare] 30 | for(int i=0; i<n; i++){ | ~^~ input/code.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int' and 'ull' {aka 'long long unsigned int'} [-Wsign-compare] 36 | for(int i=0; i<n; i++){ | ~^~
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; // unsigned l[(int)1e5+2]; // unsigned e[(int)1e5+2]; bool v[(int)1e5+2]; int main(){ ios::sync_with_stdio(0); cin.tie(0); ull n; cin >> n; map<ull, ull> e; vector<ull> as; as.reserve(n); for(ull i=0; i<n; i++){ ull a; cin >> a; as.push_back(a); } vector<ull> b = as; sort(b.begin(), b.end()); for(int i=0; i<n; i++){ auto it = find(as.begin(), as.end(), as[i]); e[as[i]] = (int)(it - as.begin()); } ull c = 0; for(int i=0; i<n; i++){ ull a = as[i]; if(!v[a]){ v[a] = 1; ull b = e[a]; while(!v[b]){ v[b] = 1; b = e[b]; c++; } v[a] = 1; } } cout << (c-1) << "\n"; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 14 |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: WRONG ANSWER
input |
---|
2 18 1 |
correct output |
---|
1 |
user output |
---|
0 |
Test 3
Verdict: WRONG ANSWER
input |
---|
2 3 8 |
correct output |
---|
0 |
user output |
---|
1 |
Test 4
Verdict: WRONG ANSWER
input |
---|
3 6 13 8 |
correct output |
---|
1 |
user output |
---|
2 |
Test 5
Verdict: WRONG ANSWER
input |
---|
3 8 6 14 |
correct output |
---|
1 |
user output |
---|
2 |
Test 6
Verdict: WRONG ANSWER
input |
---|
3 19 11 5 |
correct output |
---|
1 |
user output |
---|
2 |
Test 7
Verdict: WRONG ANSWER
input |
---|
4 17 15 16 13 |
correct output |
---|
1 |
user output |
---|
3 |
Test 8
Verdict: WRONG ANSWER
input |
---|
4 16 8 12 19 |
correct output |
---|
2 |
user output |
---|
3 |
Test 9
Verdict: ACCEPTED
input |
---|
4 13 18 5 15 |
correct output |
---|
3 |
user output |
---|
3 |
Test 10
Verdict: ACCEPTED
input |
---|
4 20 18 11 17 |
correct output |
---|
3 |
user output |
---|
3 |
Test 11
Verdict: WRONG ANSWER
input |
---|
5 17 12 15 13 11 |
correct output |
---|
2 |
user output |
---|
4 |
Test 12
Verdict: ACCEPTED
input |
---|
5 15 20 9 1 19 |
correct output |
---|
4 |
user output |
---|
4 |
Test 13
Verdict: ACCEPTED
input |
---|
5 1 11 9 19 4 |
correct output |
---|
2 |
user output |
---|
2 |
Test 14
Verdict: WRONG ANSWER
input |
---|
5 17 2 15 6 12 |
correct output |
---|
4 |
user output |
---|
3 |
Test 15
Verdict: ACCEPTED
input |
---|
5 4 18 20 11 19 |
correct output |
---|
3 |
user output |
---|
3 |
Test 16
Verdict: WRONG ANSWER
input |
---|
5 2 5 8 17 18 |
correct output |
---|
0 |
user output |
---|
3 |
Test 17
Verdict: ACCEPTED
input |
---|
5 19 5 7 17 18 |
correct output |
---|
4 |
user output |
---|
4 |
Test 18
Verdict: WRONG ANSWER
input |
---|
5 2 5 9 7 16 |
correct output |
---|
1 |
user output |
---|
3 |
Test 19
Verdict: WRONG ANSWER
input |
---|
5 8 20 1 18 5 |
correct output |
---|
2 |
user output |
---|
4 |
Test 20
Verdict: WRONG ANSWER
input |
---|
5 10 8 11 3 1 |
correct output |
---|
4 |
user output |
---|
3 |
Test 21
Verdict: ACCEPTED
input |
---|
10 8 18 15 13 6 12 9 17 2 11 |
correct output |
---|
6 |
user output |
---|
6 |
Test 22
Verdict: WRONG ANSWER
input |
---|
10 5 7 1 19 9 20 8 3 2 15 |
correct output |
---|
9 |
user output |
---|
6 |
Test 23
Verdict: WRONG ANSWER
input |
---|
10 5 11 10 7 4 14 19 1 9 13 |
correct output |
---|
8 |
user output |
---|
6 |
Test 24
Verdict: WRONG ANSWER
input |
---|
10 17 12 2 3 18 15 9 6 11 1 |
correct output |
---|
9 |
user output |
---|
7 |
Test 25
Verdict: ACCEPTED
input |
---|
10 18 13 20 12 4 5 19 15 14 11 |
correct output |
---|
7 |
user output |
---|
7 |
Test 26
Verdict: WRONG ANSWER
input |
---|
10 18 8 17 2 10 13 16 5 19 20 |
correct output |
---|
7 |
user output |
---|
8 |
Test 27
Verdict: WRONG ANSWER
input |
---|
10 3 5 18 19 17 2 1 20 8 7 |
correct output |
---|
8 |
user output |
---|
6 |
Test 28
Verdict: ACCEPTED
input |
---|
10 9 7 16 5 20 2 10 15 11 6 |
correct output |
---|
7 |
user output |
---|
7 |
Test 29
Verdict: WRONG ANSWER
input |
---|
10 17 8 11 20 18 5 16 9 1 13 |
correct output |
---|
8 |
user output |
---|
6 |
Test 30
Verdict: WRONG ANSWER
input |
---|
10 5 10 11 2 1 7 3 9 18 8 |
correct output |
---|
9 |
user output |
---|
6 |
Test 31
Verdict: RUNTIME ERROR
input |
---|
100 567896598 831327091 483130123 ... |
correct output |
---|
95 |
user output |
---|
(empty) |
Test 32
Verdict: RUNTIME ERROR
input |
---|
100 253498609 556362063 442153869 ... |
correct output |
---|
95 |
user output |
---|
(empty) |
Test 33
Verdict: RUNTIME ERROR
input |
---|
100 833824080 874174469 536879893 ... |
correct output |
---|
96 |
user output |
---|
(empty) |
Test 34
Verdict: RUNTIME ERROR
input |
---|
100 55262494 701594610 766185388 6... |
correct output |
---|
98 |
user output |
---|
(empty) |
Test 35
Verdict: RUNTIME ERROR
input |
---|
100 385222461 258813232 585406893 ... |
correct output |
---|
95 |
user output |
---|
(empty) |
Test 36
Verdict: RUNTIME ERROR
input |
---|
100 528427003 520690782 556647080 ... |
correct output |
---|
92 |
user output |
---|
(empty) |
Test 37
Verdict: RUNTIME ERROR
input |
---|
100 845689539 115595477 723524474 ... |
correct output |
---|
95 |
user output |
---|
(empty) |
Test 38
Verdict: RUNTIME ERROR
input |
---|
100 566683130 399845016 457901037 ... |
correct output |
---|
98 |
user output |
---|
(empty) |
Test 39
Verdict: RUNTIME ERROR
input |
---|
100 401801721 431563805 933290530 ... |
correct output |
---|
95 |
user output |
---|
(empty) |
Test 40
Verdict: RUNTIME ERROR
input |
---|
100 941909102 224913296 697438766 ... |
correct output |
---|
97 |
user output |
---|
(empty) |
Test 41
Verdict: RUNTIME ERROR
input |
---|
200 444811497 903431470 720091934 ... |
correct output |
---|
191 |
user output |
---|
(empty) |
Test 42
Verdict: RUNTIME ERROR
input |
---|
200 336536656 534840541 835789078 ... |
correct output |
---|
194 |
user output |
---|
(empty) |
Test 43
Verdict: RUNTIME ERROR
input |
---|
200 395789335 866736363 824087376 ... |
correct output |
---|
195 |
user output |
---|
(empty) |
Test 44
Verdict: RUNTIME ERROR
input |
---|
200 238325464 289089504 743727937 ... |
correct output |
---|
192 |
user output |
---|
(empty) |
Test 45
Verdict: RUNTIME ERROR
input |
---|
200 718880754 431102449 403271411 ... |
correct output |
---|
197 |
user output |
---|
(empty) |
Test 46
Verdict: RUNTIME ERROR
input |
---|
200 97225921 989421484 860498340 2... |
correct output |
---|
194 |
user output |
---|
(empty) |
Test 47
Verdict: RUNTIME ERROR
input |
---|
200 296729043 504301807 26318971 8... |
correct output |
---|
193 |
user output |
---|
(empty) |
Test 48
Verdict: RUNTIME ERROR
input |
---|
200 903692950 776814822 973264570 ... |
correct output |
---|
196 |
user output |
---|
(empty) |
Test 49
Verdict: RUNTIME ERROR
input |
---|
200 290066783 874736248 463312759 ... |
correct output |
---|
192 |
user output |
---|
(empty) |
Test 50
Verdict: RUNTIME ERROR
input |
---|
200 973107823 90258367 557823872 1... |
correct output |
---|
194 |
user output |
---|
(empty) |
Test 51
Verdict: RUNTIME ERROR
input |
---|
1000 592912152 847045692 284064425 ... |
correct output |
---|
990 |
user output |
---|
(empty) |
Test 52
Verdict: RUNTIME ERROR
input |
---|
1000 407810678 616563051 942898335 ... |
correct output |
---|
990 |
user output |
---|
(empty) |
Test 53
Verdict: RUNTIME ERROR
input |
---|
1000 618641025 671935409 944035992 ... |
correct output |
---|
993 |
user output |
---|
(empty) |
Test 54
Verdict: RUNTIME ERROR
input |
---|
1000 366766968 558964810 539824828 ... |
correct output |
---|
994 |
user output |
---|
(empty) |
Test 55
Verdict: RUNTIME ERROR
input |
---|
1000 307827860 66173733 860833950 9... |
correct output |
---|
994 |
user output |
---|
(empty) |
Test 56
Verdict: RUNTIME ERROR
input |
---|
1000 249869917 995683003 692483481 ... |
correct output |
---|
991 |
user output |
---|
(empty) |
Test 57
Verdict: RUNTIME ERROR
input |
---|
1000 955687818 719718081 43478262 6... |
correct output |
---|
990 |
user output |
---|
(empty) |
Test 58
Verdict: RUNTIME ERROR
input |
---|
1000 734196441 465297605 360643915 ... |
correct output |
---|
992 |
user output |
---|
(empty) |
Test 59
Verdict: RUNTIME ERROR
input |
---|
1000 851978986 549468516 638503725 ... |
correct output |
---|
988 |
user output |
---|
(empty) |
Test 60
Verdict: RUNTIME ERROR
input |
---|
1000 310014536 901327171 160589368 ... |
correct output |
---|
992 |
user output |
---|
(empty) |
Test 61
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 614666693 269733332 88642683 5... |
correct output |
---|
99989 |
user output |
---|
(empty) |
Test 62
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 272940982 811925955 61591592 5... |
correct output |
---|
99992 |
user output |
---|
(empty) |
Test 63
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 620599476 742651279 318143272 ... |
correct output |
---|
99989 |
user output |
---|
(empty) |
Test 64
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 848936553 838116035 936109023 ... |
correct output |
---|
99983 |
user output |
---|
(empty) |
Test 65
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 480849086 599714294 875965742 ... |
correct output |
---|
99984 |
user output |
---|
(empty) |
Test 66
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 888068198 739874627 942196434 ... |
correct output |
---|
99987 |
user output |
---|
(empty) |
Test 67
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 169827791 713679537 698075748 ... |
correct output |
---|
99986 |
user output |
---|
(empty) |
Test 68
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 636712086 376507123 906440322 ... |
correct output |
---|
99987 |
user output |
---|
(empty) |
Test 69
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 300349845 13933235 833947124 8... |
correct output |
---|
99985 |
user output |
---|
(empty) |
Test 70
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 200888519 710864746 665880694 ... |
correct output |
---|
99985 |
user output |
---|
(empty) |