Alien Language


/* Qualification Round 2009
http://code.google.com/codejam/contest/dashboard?c=90101#
Author : Tausiq
*/

#include
#include
using namespace std;

char query [10000];

bool check (char str [])
{
int index = 0;
//unsigned int length = strlen (query);

for ( unsigned int i = 0; i < strlen (str); i++ ) { if ( query [index] == '(' ) { index++; bool flag = false; while ( query [index] != ')' ) { if ( query [index] == str [i] ) flag = true; index++; } if ( !flag ) return false; } else { if ( query [index] != str [i] ) return false; } index++; } return true; } int main () { int l; int d; int n; int testCase = 0; cin >> l >> d >> n;

char str [5002] [18];

for ( int i = 0; i < d; i++ ) cin >> str [i];

while ( n– ) {

cin >> query;

int count = 0;
for ( int i = 0; i < d; i++ ) { if ( check (str [i]) ) count++; } printf ("Case #%d: %d\n", ++testCase, count); } return 0; } [/sourcecode]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s