1 #include <cstdio> 2 #include <iostream> 3 #include <string> 4 #include <sstream> 5 #include <algorithm> 6 #include <vector> 7 using namespace std; 8 9 #define GI ({int _t; scanf("%d", &_t); _t;}) 10 #define FOR(i, a, b) for (int i=a; i<b; i++) 11 #define REP(i, a) FOR(i, 0, a) 12 #define sz size() 13 #define pb push_back 14 template<class T> void stov(string s,vector<T> &vi){vi.clear();istringstream sin(s);for(T v;sin>>v;vi.push_back(v));} 15 16 int main() { 17 string s; 18 vector <int> v, t; 19 while (getline(cin, s)) { 20 if (s.sz == 0) break; 21 cout << s << endl; 22 stov(s, v); 23 t = v; 24 vector <int>::iterator it; 25 sort (t.begin(), t.end()); 26 int pos = -1; 27 for (int i=v.sz-1; i>=0; i--) { 28 if (v[i]!= t[i]) { 29 it = max_element(v.begin(), v.begin()+i); 30 if (it-v.begin() > 0) { 31 reverse(v.begin(), it+1); 32 printf("%d ", v.sz-(it-v.begin())); 33 } 34 reverse(v.begin(), v.begin()+i+1); 35 pos = v.sz - i; 36 printf("%d ", pos); 37 } 38 } 39 printf("0\n"); 40 41 } 42 }