Task: | Järjestys |
Sender: | 3isagreatnumber |
Submission time: | 2016-10-05 15:51:25 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.05 s | 1 | details |
#2 | WRONG ANSWER | 0.06 s | 2 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:49:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < moves.size(); i++) cout << moves[i] << " "; ^ input/code.cpp: In function 'void print(std::vector<int>*)': input/code.cpp:70:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < (*list_p).size(); i++) ^
Code
#include <iostream> #include <vector> using namespace std; // prototypes int swap(vector<int> *list_p, int n); void print(vector<int> *list_p); int main(void) { // variables int n; int m; vector<int> list; vector<int> moves; // populate list cin >> n; for (int i = 0; i < n; i++) { cin >> m; list.push_back(m); } // locate 1 and move to to correct position //print(&list); for (int i = 0; i < n; i++) { if (list[i] == 1) swap(&list, i); } //print(&list); for (int i = n; i > 1; i--) { for (int j = 0; j < n; j++) { if (list[j] == i) { moves.push_back(swap(&list, j-1)); moves.push_back(swap(&list, j)); moves.push_back(swap(&list, 1)); continue; } } } cout << moves.size() << '\n'; for (int i = 0; i < moves.size(); i++) cout << moves[i] << " "; //cout << endl; //for (int i = 0; i < list.size(); i++) cout << list[i] << " "; //cout << endl; return 0; } int swap(vector<int> *list_p, int k) { int c = k/2; for (int i = 0; i <= c; i++) { int tmp = (*list_p)[i]; (*list_p)[i] = (*list_p)[k-i]; (*list_p)[k-i] = tmp; } return k+1; } void print(vector<int> *list_p) { for (int i = 0; i < (*list_p).size(); i++) { cout << (*list_p)[i] << " "; } cout << endl; }
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
input |
---|
10 9 3 4 7 6 5 10 2 8 1 |
correct output |
---|
32 10 10 9 10 9 8 7 9 4 2 1 4 5 2... |
user output |
---|
27 3 4 2 9 10 2 3 4 2 7 8 2 7 8 2... |
Test 2
Group: 2
Verdict: WRONG ANSWER
input |
---|
1000 650 716 982 41 133 1000 876 92... |
correct output |
---|
3984 207 207 206 207 128 127 126 12... |
user output |
---|
2997 201 202 2 111 112 2 77 78 2 79... |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 94703 47808 62366 31885 7091 8... |
correct output |
---|
399956 98676 98676 98675 98676 62994 ... |
user output |
---|
(empty) |