2023.cpp

来自「这是哈尔滨工业大学acmOJ的源代码」· C++ 代码 · 共 31 行

CPP
31
字号
/*  This Code is Submitted by wywcgs for Problem 2023 on 2006-06-01 at 18:49:35 */ 
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int L = 256;

int main()
{
	char a[L], b[L], c[2*L];
	int t, T, i, j;
	bool legal[L][L];

	scanf("%d", &T);
	for(t = 1; t <= T; t++) {
		scanf("%s %s %s", a, b, c);
		int la = strlen(a), lb = strlen(b);
		memset(legal, false, sizeof(legal)); legal[0][0] = true;
		for(i = 0; i <= la; i++)
			for(j = 0; j <= lb; j++) {
				if(!legal[i][j]) continue;
				if(i != la && a[i] == c[i+j]) legal[i+1][j] = true;
				if(j != lb && b[j] == c[i+j]) legal[i][j+1] = true;
			}
		printf("Data set %d: %s\n", t, legal[la][lb] ? "yes" : "no");
	}
	
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?