Task: | Pair sort |
Sender: | aalto2024d_004 |
Submission time: | 2024-09-25 16:35:32 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 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 | WRONG ANSWER | 0.01 s | details |
#10 | WRONG ANSWER | 0.01 s | details |
#11 | WRONG ANSWER | 0.01 s | details |
#12 | WRONG ANSWER | 0.01 s | details |
#13 | WRONG ANSWER | 0.02 s | details |
#14 | WRONG ANSWER | 0.02 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:47:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare] 47 | for(int i=0; i< swaps.size(); i++){ | ~^~~~~~~~~~~~~~
Code
#include <iostream> #include <vector> using namespace std; void swap(vector<int>& vec, int a, int b){ int i = vec[a]; vec[a] = vec[b]; vec[b] = i; } int find_pos(const vector<int>& vec, int min, int find){ for(int i=vec.size(); i>min; i--){ if(vec[i]==find)return i; } return -1; } int main(){ int n; cin >> n; vector<int> vec((2*n)); for(int i=0; i<2*n; i++) cin >> vec[i]; vector<pair<int,int>> swaps; int num = vec[0]; for(int i=1; i<2*n; i++){ if((i%2)==1){ if(vec[i]!=num){ int pos = find_pos(vec, i, num); swaps.push_back(make_pair(i, pos)); swap(vec,i,pos); } } else{ num=vec[i]; } } cout << swaps.size() <<endl; for(int i=0; i< swaps.size(); i++){ cout << swaps[i].first << " " <<swaps[i].second <<endl; } }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
5 3 2 4 5 1 3 2 1 4 5 |
correct output |
---|
3 2 6 4 9 6 8 |
user output |
---|
3 1 5 3 8 5 7 |
Test 2
Verdict: WRONG ANSWER
input |
---|
5 3 2 4 5 1 3 2 1 4 5 |
correct output |
---|
3 2 6 4 9 6 8 |
user output |
---|
3 1 5 3 8 5 7 |
Test 3
Verdict: WRONG ANSWER
input |
---|
10 3 6 6 8 8 9 9 1 4 5 2 4 10 2 1... |
correct output |
---|
9 2 17 4 17 6 17 8 17 ... |
user output |
---|
9 1 16 3 16 5 16 7 16 ... |
Test 4
Verdict: WRONG ANSWER
input |
---|
10 3 6 6 8 8 9 9 1 4 5 2 4 10 2 1... |
correct output |
---|
9 2 17 4 17 6 17 8 17 ... |
user output |
---|
9 1 16 3 16 5 16 7 16 ... |
Test 5
Verdict: WRONG ANSWER
input |
---|
50 47 26 6 35 13 18 9 19 14 50 34... |
correct output |
---|
48 2 87 4 78 6 71 8 55 ... |
user output |
---|
48 1 86 3 77 5 70 7 54 ... Truncated |
Test 6
Verdict: WRONG ANSWER
input |
---|
50 47 26 6 35 13 18 9 19 14 50 34... |
correct output |
---|
48 2 87 4 78 6 71 8 55 ... |
user output |
---|
48 1 86 3 77 5 70 7 54 ... Truncated |
Test 7
Verdict: WRONG ANSWER
input |
---|
100 56 26 6 35 60 72 9 55 83 51 58... |
correct output |
---|
97 2 77 4 108 6 141 8 55 ... |
user output |
---|
97 1 76 3 107 5 140 7 54 ... Truncated |
Test 8
Verdict: WRONG ANSWER
input |
---|
100 56 26 6 35 60 72 9 55 83 51 58... |
correct output |
---|
97 2 77 4 108 6 141 8 55 ... |
user output |
---|
97 1 76 3 107 5 140 7 54 ... Truncated |
Test 9
Verdict: WRONG ANSWER
input |
---|
500 56 146 351 35 281 235 354 449 ... |
correct output |
---|
497 2 758 4 820 6 125 8 243 ... |
user output |
---|
497 1 757 3 819 5 124 7 242 ... Truncated |
Test 10
Verdict: WRONG ANSWER
input |
---|
500 56 146 351 35 281 235 354 449 ... |
correct output |
---|
497 2 758 4 820 6 125 8 243 ... |
user output |
---|
497 1 757 3 819 5 124 7 242 ... Truncated |
Test 11
Verdict: WRONG ANSWER
input |
---|
1000 603 596 351 885 530 235 354 56... |
correct output |
---|
993 2 256 4 1534 6 816 8 1057 ... |
user output |
---|
993 1 255 3 1533 5 815 7 1056 ... Truncated |
Test 12
Verdict: WRONG ANSWER
input |
---|
1000 603 596 351 885 530 235 354 56... |
correct output |
---|
993 2 256 4 1534 6 816 8 1057 ... |
user output |
---|
993 1 255 3 1533 5 815 7 1056 ... Truncated |
Test 13
Verdict: WRONG ANSWER
input |
---|
5000 1594 596 1797 3776 1201 235 35... |
correct output |
---|
4993 2 1548 4 9062 6 6397 8 8296 ... |
user output |
---|
4993 1 1547 3 9061 5 6396 7 8295 ... Truncated |
Test 14
Verdict: WRONG ANSWER
input |
---|
5000 1594 596 1797 3776 1201 235 35... |
correct output |
---|
4993 2 1548 4 9062 6 6397 8 8296 ... |
user output |
---|
4993 1 1547 3 9061 5 6396 7 8295 ... Truncated |