#include <iostream>
#include <queue>
#include <climits>
#include <cstring>
using namespace std;
const int MAX_SIZE = 400;
int capacity[MAX_SIZE][MAX_SIZE];
int parent[MAX_SIZE];
bool visit[MAX_SIZE]; bool Edmonds_Karp( int start, int end ){
queue<int> Q;
memset( visit, false, sizeof( visit ) );
visit[start] = true;
Q.push( start );
while( !Q.empty() ){
int temp = Q.front();
Q.pop();
for( int i = start; i <= end; ++i ){
if( capacity[temp][i] && !visit[i] ){
visit[i] = true;
parent[i] = temp;
Q.push( i );
if( i == end ) return true;
}
}
}
return false;
} int Ford_Fulkerson( int start, int end ){
int max_flow = 0;
while( true ){
if( !Edmonds_Karp( start, end ) ) break;
int flow = INT_MAX;
int path = end;
while( path != start ){
flow = min( flow, capacity[parent[path]][path] );
path = parent[path];
}
path = end;
while( path != start ){
capacity[path][parent[path]] += flow;
capacity[parent[path]][path] -= flow;
path = parent[path];
}
max_flow += flow;
}
return max_flow;
} int main(){
int t;
cin>>t;
while( t-- ){
int start = 0;
int end = MAX_SIZE - 1;
memset( capacity, 0, sizeof( capacity ) );
int film_num;
int sum_day = 0;
cin>>film_num;
for( int i = 1; i <= film_num; ++i ){
int flag[8];
int day, week;
for( int j = 1; j <= 7; ++j ) cin>>flag[j];
cin>>day>>week;
capacity[start][i] = day;
sum_day += day;
for( int p = 0; p < week; ++p ){
for( int q = 1; q <= 7; ++q ){
int index = film_num + 7 * p + q;
capacity[i][index] = flag[q];
if( flag[q] ) capacity[index][end] = 1;
}
}
}
/*
for( int i = 0; i <= film_num; ++i ){
for( int j = 0; j <= 40; ++j ){
cout<<capacity[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;*/
int max_flow = Ford_Fulkerson( start, end );
if( max_flow == sum_day ) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}

POJ_1698_Alice's Chance的更多相关文章

  1. Chance – 功能强大的 JavaScript 随机数生成类库

    Chance 是一个基于 JavaScript 的随机数工具类.可以生成随机数字,名称,地址,域名,邮箱,时间等等,几乎网站中使用的任何形式的内容都能够生成.这个随机数工具可以帮助减少单调的测试数据编 ...

  2. poj 1698 Alice‘s Chance

    poj 1698  Alice's Chance 题目地址: http://poj.org/problem?id=1698 题意: 演员Alice ,面对n场电影,每场电影拍摄持续w周,每周特定几天拍 ...

  3. 【性能诊断】九、并发场景的性能分析(windbg案例,Fist Chance Exception/Crash dump)

          经常会碰到这样的场景,自测及单单点的测试时没有任何问题,但在并发环境或生产环境下有时出现没规律的异常.报错等情况.在代码中增加日志是其中一种解决方式:抓取指定异常时的dump,通过wind ...

  4. (C# Debug)A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll

    Debug 模式下运行程序的时候,Output 窗口出来个错误“A first chance exception of type 'System.ArgumentException' occurred ...

  5. Alice's Chance POJ - 1698(按时间点建边)

    Alice's Chance Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7791   Accepted: 3174 De ...

  6. 2018.07.06 POJ1698 Alice's Chance(最大流)

    Alice's Chance Time Limit: 1000MS Memory Limit: 10000K Description Alice, a charming girl, have been ...

  7. You can fail at what you don't want, so you might as well take a chance on doing what you love.

    You can fail at what you don't want, so you might as well take a chance on doing what you love. 做不想做 ...

  8. Opportunity的chance of success的赋值逻辑

    该字段的值和另外两个字段Sales Stage和Status都相关. 从下列function module CRM_OPPORT_H_PROB_SET_EC可看出,当status不为代码中的这些硬编码 ...

  9. 理解First Chance和Second Chance避免单步调试

    原文链接地址:http://blog.csdn.net/Donjuan/article/details/3859160 在现在C++.Java..Net代码大行其道的时候,很多代码错误(Bug)都是通 ...

随机推荐

  1. c reference

    1,函数:strdup复制字符串函数原型定义:char * strdup(const char *s);函数说明:strdup()会先用maolloc()配置与参数s字符串相同的空间大小,然后将参数s ...

  2. iOS 处理方法中的可变參数

    ## iOS 处理方法中的可变參数 近期写了一个自己定义的对话框的demo,想模仿系统的UIAlertView的实现方式.对处理可变參数的时候,遇到了小问题,于是谷歌了一下.写下了处理问题的方法.记录 ...

  3. iOS_词典阵列 按key分组和排序

    // // main.m // SortGroup // // Created by beyond on 14-10-26. // Copyright (c) 2014年 beyond.com All ...

  4. Android解析XML

    在Android平台上可以使用Simple API for XML(SAX) . Document Object Model(DOM)和Android附带的pull解析器解析XML文件. 下面是本例子 ...

  5. Spring MVC 完整示例

    在本例中,我们将使用Spring MVC框架构建一个入门级web应用程序.Spring MVC 是Spring框架最重要的的模块之一.它以强大的Spring IoC容器为基础,并充分利用容器的特性来简 ...

  6. ##DAY9 UITabBarController

    ##DAY9 UITabBarController UIViewController的tabBarController UIViewController的tabBarItem #pragma mark ...

  7. 最近比较迷flash professional cc 做PPT,做一个flash做动态打字效果的教程

    想做一个flash打字效果.网上的方法要不是太繁琐,要不然就是各种遗漏.在这边做一个行之有效的flash做打字效果教程. 首先我用的是最新版本的flash professional cc .但是应该和 ...

  8. 容易被误解的overflow:hidden

    http://www.ofcss.com/2011/03/20/misunderstood-of-overflow-hidden.html(转) 容易被误解的overflow:hidden 15条评论 ...

  9. eclipse run on server 浏览器启动设置

  10. 四轴飞行器1.3 MPU6050(大端)和M4的FPU开启方法

    四轴飞行器1.3 MPU6050(大端)和M4的FPU开启方法  原创文章,欢迎转载,转载请注明出处      最近时间花在最多的地方就是STM32的I2C上了.之前就知道STM32的I2C并不好用, ...