| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
哈哈,谢谢这位仁兄的指点,一语道破天机啊!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator