Artifact 6442f8ba618ca35382ba360eb65fb0a6788f0bfa
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class PermutationSignature { public:
vector <int> reconstruct(string signature)
{
deque<int> cur(1, 1);
for(int i=signature.size()-1; i>=0; --i)
{
int ins = (signature[i]=='I' ? 1 : cur.front()+1);
cur.push_front(ins);
for(int k=1; k<cur.size(); ++k)
if( cur[k] >= ins )
cur[k] ++;
}
return vector<int>(cur.begin(), cur.end());
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const vector <int>& Expected, const vector <int>& Received) {
bool ok = (Expected == Received);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: " << Expected << endl << "\tx: " << Received << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, PermutationSignature().reconstruct(signature));}
int main(){
CASE(0)
string signature = "IIIII";
int __[] = {1, 2, 3, 4, 5, 6 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(1)
string signature = "DI";
int __[] = {2, 1, 3 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(2)
string signature = "IIIID";
int __[] = {1, 2, 3, 4, 6, 5 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(3)
string signature = "DIIDID";
int __[] = {2, 1, 3, 5, 4, 7, 6 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(4)
string signature = "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD";
int __[] = {-1};
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(5)
string signature = "IDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDID";
int __[] = {-1};
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(6)
string signature = "I";
int __[] = {1,2};
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(7)
string signature = "D";
int __[] = {2,1};
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
}
// END CUT HERE