Rezultati

Up. imeNalogaJezikRezultatČas oddaje
lisperator-2017 Prijateljske besede C++ 100/100OK 20. apr '17 @ 17:29

Test Točke Porabljen spomin Porabljen čas Status
#1 12/12 3,117 MiB 0,004 s OK
#2 12/12 3,125 MiB 0,004 s OK
#3 12/12 3,223 MiB 0,455 s OK
#4 12/12 3,219 MiB 0,461 s OK
#5 13/13 3,211 MiB 0,028 s OK
#6 13/13 3,219 MiB 0,284 s OK
#7 13/13 3,211 MiB 0,010 s OK
#8 13/13 3,219 MiB 0,375 s OK

Ocenjevani program (Source (7).cpp):
#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	string* data = new string[N];
	bool* checked = new bool[N];
	vector<int> pending;
	pending.reserve(3000);

	for (int i = 0; i != N; i++)
	{
		string str;
		cin >> str;
		data[i] = str;
		checked[i] = false;
	}
	pending.push_back(0);
	checked[0] = true;
	int count = 1;


	while (pending.size() != 0)
	{
		string current = data[pending[pending.size() - 1]];
		pending.pop_back();

		for (int i = 0; i != N; i++)
		{
			if (checked[i] == false &&
				(current.substr(0, 3) == data[i].substr(0, 3) ||
					current.substr(current.size() - 3, current.size()) == data[i].substr(data[i].size() - 3, data[i].size())))
			{
				checked[i] = true;
				pending.push_back(i);
				count++;
			}
		}
	}

	cout << count << endl;
	//system("pause");

	return 0;
}