All pastes #952894 Raw Edit

Stuff

public text v1 · immutable
#952894 ·published 2008-03-22 16:56 UTC
rendered paste body
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class RoughStrings {
public:
	int minRoughness(string, int);
	int calRoughness(string );
};

int RoughStrings::minRoughness(string s, int n) 
{
	int ans = calRoughness(s);
	vector <int> pos (s.size());
	
	for(int i = 0; i < s.size(); i++)
	{
		pos[i] = s.size()-1-i;
	}
	
	for(int r = 1; r <= n; ++r)
	{
		do{
			string str = s;
			vector <int> remove(r);
			for(int i = 0; i < r; ++i)
				remove.push_back(pos[i]);
			
			for(int i = 0; i < r; ++i)
			{
				str.erase(s.begin()+remove[i],1);
			}
			
			ans = min (ans, calRoughness(str));
		}
		while(next_permutation(pos.begin(), pos.end()));
		reverse(pos.begin(), pos.end());
	}
	
	return ans;
}

int Roughness::calRoughness(string );
<%:testing-code%>
//Powered by [KawigiEdit] 2.0!