Ejemplo n.º 1
0
int countInv(ST st) {
	int ret = 0;
	forn(i, st.size()) 
		forab(j, i+1, st.size() - 1)
			if(st[j] < st[i])
				ret++;
	return ret;
}
Ejemplo n.º 2
0
int main()
{
	int N;
	ST st;

	cin >> N >> st;

	map <char, int> mp;

	forn(i, st.size())
		mp[st[i]]++;

	ST ret;
	tr(it, mp) {
	       	if(it->second % N != 0 ) {
			cout << -1 << endl;
			return 0;
		}
		forn(i, it->second/N)
			ret += it->first;
	}
	forn(i, N)
		cout << ret;
	cout << endl;

	return 0;
}
bool process(ST file) {
	ifstream in1(file.c_str());
	if(in1 == nullptr) 
		return false;
	ST outfile = "ocf." + file;
	ofstream out1(outfile.c_str());

	ST st;
	vs includes;
	while(getline(in1, st)) {
		if(st.size() >= 8 && st.substr(0, 8) == "#include")
			includes.pb(st);
		else
			out1 << st << endl;
	}
	out1.flush();
	ST tmpfile = "sqae." + file;
	ST command = "cpp " + outfile + " > " + tmpfile;
	system(command.c_str());

	int idx = file.find_first_of('.');
//	ST name = file.substr(0, idx) + "_new.cpp";
	ST name = file.substr(0, idx) + "_preprocessed.cpp";

	ifstream in2(tmpfile.c_str());
//	ofstream out2(("new_" + file).c_str());
	ofstream out2(name.c_str());
	bool isTypedef = false;

//	out2 << "//%%%%%%%%%%%%\n//%%%%lost%%%%\n//%%%%%%%%%%%%\n\n";
	out2 << 
		"//Name         : Shinchan Nohara\n"
		"//Age          : 5 years\n"
		"//Organisation : Kasukabe Defense Force\n\n";

	for(auto &x: includes)
		out2 << x << endl;

	bool blankLine = false;
	while(getline(in2, st)) {
		if(st.size() >= 2 && st.substr(0, 2) == "# ")
			continue;
		if(blankLine && st == "")
			continue;
		blankLine = false;

		if(isTypedef && !(st.size() >= 7 && st.substr(0, 7) == "typedef"))
			out2 << endl;

		if(st.size() >= 7 && st.substr(0, 7) == "typedef") {
			isTypedef = true;
			out2 << endl;
		}

		if(st == "")
			blankLine = true;
		int i;
		for(i = 0; i < st.size() && st[i] == ' '; i++)
			out2 << "\t";
		out2 << st.substr(i);
	}

	system(("rm " + tmpfile).c_str());
	system(("rm " + outfile).c_str());
	return true;
}
Ejemplo n.º 4
0
#ifdef DEBUG
	#undef DEBUG
#endif
#define DEBUG

ST s, t;
vi mx, mn;
vector <bool> in;

int main()
{
	cin >> s >> t;
	DEBUG(s);
	DEBUG(t);

	mx.resize(s.size(), 0);
	mn.resize(s.size(), t.size());
	in.resize(s.size(), false);

	if(s.size() < t.size() || s.front() != t.front() || s.back() != t.back()) {
		DEBUG("#0");
		cout << "No" << endl;
		return 0;
	}

	mx[0] = 1;
	in[0] = true;

	int tidx = 1;

	for(int sidx = 1; sidx < s.size() && tidx < t.size(); sidx++) {