// Problem A. The Last Word
// Problem URL: https://code.google.com/codejam/contest/4304486/dashboard#s=p0&a=0
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <limits>
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<long long> vll;
void solve()
{
int numCases = 1;
cin >> numCases;
for ( int ncase=1; ncase <= numCases; ncase++ )
{
//===== start case
string S;
cin >> S;
string ans=S.substr(0,1);
for ( int i=1; i<S.size(); i++ )
{
if (S[i]>=ans[0])
ans = S.substr(i,1) + ans;
else
ans = ans + S.substr(i,1);
}
cout << "Case #" << ncase << ": ";
cout << ans << endl;
//===== end case
}
}
int main()
{
solve();
return 0;
}
No comments:
Post a Comment