Pagini recente » Cod sursa (job #639148) | Atasamentele paginii dif2 | Diferente pentru problema/pizza intre reviziile 21 si 2 | Diferente pentru adobe-code-pandas/runda-1 intre reviziile 4 si 14 | Cod sursa (job #1765650)
#include <iostream>
#include <algorithm>
#include <fstream>
using namespace std;
bool valid(string s)
{
for(int i=0; i<s.size()-1; ++i)
if(s[i]==s[i+1])
return 0;
return 1;
}
int main()
{ ifstream f("ordine.in");
string s,c;
f >> s;
do
{
if(valid(s))
c=s;
} while(prev_permutation(s.begin(), s.end()));
ofstream g("ordine.out");
g << c << "\n";
return 0;
}