Task: | Järjestys |
Sender: | peltola |
Submission time: | 2016-10-16 23:24:33 +0300 |
Language: | C++ |
Status: | READY |
Result: | 19 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 19 |
#2 | RUNTIME ERROR | 0 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.05 s | 1 | details |
#2 | RUNTIME ERROR | 0.14 s | 2 | details |
#3 | RUNTIME ERROR | 0.69 s | 3 | details |
Code
//#include <iostream> //#include <string> //#include <algorithm> //#include <vector> #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; // string op; // op = ""; // unsigned int h; // h = 0; unsigned int x[n]; vector<unsigned int> a; for(int i = 0; i < n; i++) { int o; cin >> o; a.push_back(o); x[o - 1] = i; } vector<int> op; for(unsigned int i = n; i > 1; i--) { for(unsigned int j = x[i - 1]; j >= 0; j--) { // j = min(j, a.size() - 1); if(j >= a.size()) { j = a.size(); } if(a[j] == i) { if(j == i - 1) break; if(j + 1 > 1) { op.push_back(j + 1); // h++; } if(i > 1) { op.push_back(i); // h++; } if(i - 1 > 1) { op.push_back(i - 1); // h++; } if(j > 1) { op.push_back(j); // h++; } a.erase(a.begin() + j); break; } } } cout << op.size(); cout << "\n"; // for(int i = 0; i < op.size(); i++) { // cout << op[i]; // cout << " "; // } for(int z : op) cout << z << " "; cout << "\n"; return 0; }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
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 |
---|
28 7 10 9 6 9 8 7 8 7 6 3 7 6 2 3... |
Test 2
Group: 2
Verdict: RUNTIME ERROR
input |
---|
1000 650 716 982 41 133 1000 876 92... |
correct output |
---|
3984 207 207 206 207 128 127 126 12... |
user output |
---|
(empty) |
Test 3
Group: 3
Verdict: RUNTIME ERROR
input |
---|
100000 94703 47808 62366 31885 7091 8... |
correct output |
---|
399956 98676 98676 98675 98676 62994 ... |
user output |
---|
(empty) |