CSES - Datatähti 2017 alku - Results
Submission details
Task:Järjestys
Sender:miksu.r
Submission time:2016-10-15 10:33:09 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.05 s1details
#20.45 s2details
#3--3details

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:

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:

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:

input
100000
94703 47808 62366 31885 7091 8...

correct output
399956
98676 98676 98675 98676 62994 ...

user output
(empty)