Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哈哈,谢谢这位仁兄的指点,一语道破天机啊!

Posted by yousiki at 2016-07-31 21:37:25 on Problem 2192
In Reply To:无语了!WA 了这么多次,竟然是第3个数组开小了! Posted by:zjjla at 2009-08-17 16:26:13
小伙伴们,注意第三个串的最大长度是400哦!
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

/* debug */
ostream &debug = cout;

/* POJ 2192 */

const int N = 405;

int la, lb, lc;
char a[N], b[N], c[N];
bitset<N> dp[N];

signed main(void) {

	int T, t;
	scanf("%d", &T);
	for (t = 1; t <= T; t++) {

		/* input */
		scanf("%s%s%s", a + 1, b + 1, c + 1);

		/* prepare */
		la = strlen(a + 1);
		lb = strlen(b + 1);
		lc = strlen(c + 1);
		for (int i = 0; i < N; i++)
			dp[i].reset();
		dp[0][0] = 1;

		/* solve */
		for (int i = 0; i <= la; i++)
			for (int j = 0; j <= lb; j++)
				if (dp[i][j] && i + j < lc) {
					if (c[i + j + 1] == a[i + 1])
						dp[i + 1][j] = 1;
					if (c[i + j + 1] == b[j + 1])
						dp[i][j + 1] = 1;
				}

		/* output */
		if (dp[la][lb])
			printf("Data set %d: yes\n", t);
		else
			printf("Data set %d: no\n", t);

	}

#ifndef ONLINE_JUDGE
	system("pause");
#endif // !ONLINE_JUDGE

}	// By YOUSIKI

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator