作业帮 > 综合 > 作业

ACM 的一道题提交总是Time Limit Exceeded,求救

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/09/21 20:33:48
ACM 的一道题提交总是Time Limit Exceeded,求救
我搞了一个下午,得出的结论是本人的确是菜鸟,请各位大虾帮下忙!!!
题目:
Escape
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 15 Accepted Submission(s) : 0
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
2012 If this is the end of the world how to do? I do not know how. But now scientists have found that some stars, who can live, but some people do not fit to live some of the planet. Now scientists want your help, is to determine what all of people can live in these planets.
Input
More set of test data, the beginning of each data is n (1 <= n <= 100000), m (1 <= m <= 10) n indicate there n people on the earth, m representatives m planet, planet and people labels are from 0. Here are n lines, each line represents a suitable living conditions of people, each row has m digits, the ith digits is 1, said that a person is fit to live in the ith-planet, or is 0 for this person is not suitable for living in the ith planet.
The last line has m digits, the ith digit ai indicates the ith planet can contain ai people most..
0 <= ai <= 100000
Output
Determine whether all people can live up to these stars
If you can output YES, otherwise output NO.
Sample Input
1 1
1
1
2 2
1 0
1 0
1 1
Sample Output
YES
NO
ACM 的一道题提交总是Time Limit Exceeded,求救
你是怎么做的? 二分图的多重匹配这题,如果暴力做的话会T的
代码附一个吧:
#include
#include
#include
using namespace std;
const int N=100010;
int n,m;
int cap[11],map[N][11];
int val[11],mat[11][N];
int mark[11];
bool dfs(int x)
{
for(int i=0;im)
{
memset(map,0,sizeof(map));
for(int i=0;i