| Task: | Järjestys |
| Sender: | miksu.r |
| Submission time: | 2016-10-15 10:33:09 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | RUNTIME ERROR | 0 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.05 s | 1 | details |
| #2 | RUNTIME ERROR | 0.45 s | 2 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
unsigned long n;
string inf;
string ins;
string tmp;
unsigned long index;
unsigned long a;
unsigned long b;
vector<unsigned long> out;
int main(){
getline(cin, inf);
n = stoul(inf);
unsigned long x[n];
unsigned long y[n];
getline(cin, ins);
stringstream t(ins);
index = 0;
while(t >> tmp){
x[index] = stoul(tmp);
index++;
}
copy(x, x + n, y);
sort(x, x + n);
index = n - 1;
while(index > 0){
a = index;
for(unsigned long i = a; i; i--){
if(y[i] == x[i]){
index--;
}
if(y[i - 1] != x[i - 1]){
break;
}
}
for(unsigned long i = a; i; i--){
if(y[i] == x[index]){
b = i;
break;
}
}
out.push_back(b + 1);
reverse(y, y + b + 1);
out.push_back(index + 1);
reverse(y, y + index + 1);
}
for(unsigned int i = 0; i < out.size(); i++){
cout << out[i] << " ";
}
return 0;
}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 |
|---|
| 7 10 4 9 7 8 4 7 3 4 3 2 3 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: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 94703 47808 62366 31885 7091 8... |
| correct output |
|---|
| 399956 98676 98676 98675 98676 62994 ... |
| user output |
|---|
| (empty) |
