Untitled

mail@pastecode.io avatarunknown
plain_text
17 days ago
2.4 kB
6
Indexable
Never
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <stdio.h>

// API Command
#define CMD_INIT        100
#define CMD_ADDWORD     200
#define CMD_REMOVEWORD  300
#define CMD_SEARCHWORD  400

// User Implement API
extern void init(void);
extern void addWord(char str[]);
extern int  removeWord(char str[]);
extern int  searchWord(char str[]);

#define STRLEN_MAX 6

static int run(int score)
{
	int queryCnt;
	scanf("%d", &queryCnt);
	
	for (int q = 0; q < queryCnt; ++q)
	{
		int cmd;
		scanf("%d", &cmd);
		
		if (cmd == CMD_INIT)
		{
			init();
		}
		else if (cmd == CMD_ADDWORD)
		{
			char str[STRLEN_MAX + 1];
			scanf("%s", str);

			addWord(str);
		}
		else if (cmd == CMD_REMOVEWORD)
		{
			char str[STRLEN_MAX + 1];
			scanf("%s", str);

			int userAns = removeWord(str);

			int ans;
			scanf("%d", &ans);
			
			if (userAns != ans)
			{
				score = 0;
			}
		}
		else if (cmd == CMD_SEARCHWORD)
		{
			char str[STRLEN_MAX + 1];
			scanf("%s", str);

			int userAns = searchWord(str);

			int ans;
			scanf("%d", &ans);
			
			if (userAns != ans)
			{
				score = 0;
			}
		}
	}
	return score;
}

int main(void)
{
	setbuf(stdout, NULL);
	
	//freopen("sample_input.txt", "r", stdin);
	
	int TC;
	int targetScore;
	scanf("%d %d", &TC, &targetScore);
	
	for (int testcase = 1; testcase <= TC; ++testcase)
	{
		int score = run(targetScore);
		printf("#%d %d\n", testcase, score);
	}
	
	return 0;
}



//	 The below commented functions are for your reference. If you want 
//	 to use it, uncomment these functions.
/*
int mstrcmp(const char a[], const char b[])
{
	int i;
	for (i = 0; a[i] != '\0'; ++i) if (a[i] != b[i]) return a[i] - b[i];
	return a[i] - b[i];
}

void mstrcpy(char dest[], const char src[])
{
	int i = 0;
	while (src[i] != '\0') { dest[i] = src[i]; i++; }
	dest[i] = src[i];
}

int mstrlen(const char a[])
{
	int i;
	for (i = 0; a[i] != '\0'; ++i);
	return i;
}
*/

void init(void) 
{
}

void addWord(char str[]) 
{
}

int removeWord(char str[])
{
	return -1;
}

int searchWord(char str[])
{
	return -1;
}



10 100
18
100
200 frog
200 flag
200 flag
200 play
400 fl*g 2
400 f*g 3
300 flag 2
400 flag 0
200 slay
200 slayer
200 slave
400 slay* 2
300 *lay 2
400 s* 2
400 * 3
300 * 3
400 * 0