Rezultati

Up. imeNalogaJezikRezultatČas oddaje
kira Pasavci C++ 0/100Napaka med izvajanjem / ob izhodu (RTE) 11. maj '17 @ 18:25

Test Točke Porabljen spomin Porabljen čas Status
#1 5/5 3,426 MiB 0,004 s OK
#2 5/5 4,105 MiB 0,010 s OK
#3 5/5 11,090 MiB 0,031 s OK
#4 5/5 41,031 MiB 0,108 s OK
#5 5/5 59,059 MiB 0,143 s OK
#6 0/5 128,070 MiB 0,338 s Prekoračen spomin
#7 5/5 109,180 MiB 0,276 s OK
#8 0/5 128,078 MiB 0,332 s Prekoračen spomin
#9 0/6 128,406 MiB 0,353 s Prekoračen spomin
#10 0/6 135,605 MiB 0,319 s Prekoračen spomin
#11 6/6 3,125 MiB 0,004 s OK
#12 6/6 3,133 MiB 0,004 s OK
#13 6/6 3,117 MiB 0,004 s OK
#14 6/6 3,125 MiB 0,004 s OK
#15 6/6 6,570 MiB 0,058 s OK
#16 6/6 3,125 MiB 0,004 s OK
#17 6/6 3,152 MiB 0,004 s OK
#18 6/6 5,094 MiB 0,009 s OK

Ocenjevani program (Pasavci.cpp):
//============================================================================
// Name        : Pasavci.cpp
// Author      : Kira
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

// radical 129 ////////////////////////////////////////////
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <stack>
#include <deque>
#include <cstdlib>
#include <map>
#include <cmath>
#include <string.h>
#define pii pair<int,int>
#define pib pair<int,bool>
#define mp make_pair
#define pb push_back
#define FOR(i,n) for(int i=0,_n=n;i<_n;i++)
#define FORR(i,j,n) for(int i=j,_n=n;i<_n;i++)
using namespace std;
typedef long long ll;
// radical 159 ////////////////////////////////////////////

vector<string> genes;
int abeceda[256];

int main() {
	string p;
	cin >> p;
	string s1; string s2;
	cin >> s1 >> s2;
	genes.pb(s1);
	genes.pb(s2);
	int N;
	cin >> N;
	FOR(i,N)
	{
		int num1,num2;
		cin >> num1 >> num2;
		string n="";
		n += genes[num1-1] + genes[num2-1];
		genes.pb(n);
	}
	/*FOR(i,genes.size())
	{
		cout << "genes: " << genes[i] << endl;
	}*/
	//Hospoool
		//pre-processing
		int p_len = p.length();
		FOR(i,256){abeceda[i]=p_len;}
		for(int i=p_len-2; i>=0; i--)
		{
			if(abeceda[(int)p[i]] > p_len-i-1 )
			{
				abeceda[(int)p[i]] = p_len-i-1;
			}
		}
		//check abeceda if its correct
		/*FOR(i,256)
		{
			//if(abeceda[i]!=p_len)
			//{
				cout << (char)i << " has index: " << abeceda[i] << endl;
			//}
		}*/
		string search = genes[genes.size()-1]; int search_len = search.length();
		int result = 0;
		int i = 0, j=0;
		while(i+p_len-1<search_len)
		{
			if( search[i+p_len-1] == p[p_len-1] ) //last character is a match
			{
				//compare each character, if we find a missmatch, shift 'i' by that missmatched character and start over
				int correct = 0;
				for(j=0; j<p_len;j++)
				{
					if( search[i+j] == p[j] ){correct++;}
					else
					{
						i += abeceda[(int)search[i+p_len-1]];
						//i += abeceda[(int)p[j]];
						break;
					}
				}
				if(correct==p_len)
				{
					result++;
					i++;
				}
			}
			else
			{
				i += abeceda[(int)search[i+p_len-1]];
			}
		}
		cout << result << endl;

	return 0;
}