Videos

时间限制: 1 Sec  内存限制: 128 MB
提交: 17  解决: 7
[提交] [状态] [讨论版] [命题人:admin]

题目描述

C-bacteria takes charge of two kinds of videos: ’The Collection of Silly Games’ and ’The Collection of Horrible Games’.
For simplicity’s sake, they will be called as videoA and videoB.
There are some people who want to watch videos during today, and they will be happy after watching videos of C-bacteria.
There are n hours a day, m videos are going to be show, and the number of people is K.
Every video has a type(videoA or videoB), a running time, and the degree of happi- ness after someone watching whole of it.
People can watch videos continuous(If one video is running on 2pm to 3pm and another is 3pm to 5pm, people can watch both of them).
But each video only allows one person for watching.
For a single person, it’s better to watch two kinds to videos alternately, or he will lose W happiness.
For example, if the order of video is ’videoA, videoB, videoA, videoB, …’ or ’B, A, B, A, B, …’, he won’t lose happiness; But if the order of video is ’A, B, B, B, A, B, A, A’, he will lose 3W happiness.
Now you have to help people to maximization the sum of the degree of happiness.

输入

Multiple query.
On the first line, there is a positive integer T, which describe the number of data. Next there are T groups of data.
for each group, the first line have four positive integers n, m, K, W : n hours a day, m videos, K people, lose W happiness when watching same videos).
and then, the next m line will describe m videos, four positive integers each line S, T, w, op : video is the begin at S and end at T, the happiness that people can get is w, and op describe it’s tpye(op=0 for videoA and op=1 for videoB).
There is a blank line before each groups of data.
T<=20, n<=200, m<=200, K<=200, W<=20, 1<=S<T<=n, W<=w<=1000,op=0 or op=1

 

输出

Your output should include T lines, for each line, output the maximum happiness for the corresponding datum.

样例输入

2
10 3 1 10
1 5 1000 0
5 10 1000 1
3 9 10 0
10 3 1 10
1 5 1000 0
5 10 1000 0
3 9 10 0

样例输出

2000
1990
思路:
  最小费用最大流,人尽可能被利用才能使结果最大化!
  建立负权边,因为要使总幸福值的绝对值最大!
  源点与次源点之间建一条流量为K,费用为0的边;
  所有影片自己的起点与终点建一条流量为1,费用为-w的边;
  次源点与所有影片的起点建一条流量为1,费用为0的边;
  所有影片的终点与汇点建一条流量为1,费用为0的边;
  所有影片自己的终点与其他所有满足继承条件的影片的起点建一条流量为1,费用为0或者W的边(类型相同则为W);
AC代码:
#include <bits/stdc++.h>
using namespace std;
const int maxn=;
const int inf=0x3f3f3f3f;
struct Edge
{
int u,v,cost,cap,flow,next;
}e[maxn*maxn];
int T,n,m,k,w;
struct Mcmf
{
int head[maxn],cnt;
int dis[maxn],f[maxn],pre[maxn];
bool vis[maxn];
inline void init()
{
memset(head,-,sizeof(head));
cnt=;
}
inline void add(int u,int v,int cost,int cap,int flow=)
{
e[cnt]=Edge{u,v,cost,cap,flow,head[u]};
head[u]=cnt++;
e[cnt]=Edge{v,u,-cost,,flow,head[v]};
head[v]=cnt++;
}
bool spfa(int s,int t,int &cost,int &flow)
{
memset(vis,false,sizeof(vis));
for (int i=; i<maxn; i++)
dis[i]=inf;
queue<int>q;
f[s]=inf;
dis[s]=;
q.push(s);
while(!q.empty())
{
int u=q.front();
q.pop();
vis[u]=false;
for (int i=head[u]; i!=-; i=e[i].next)
{
int v=e[i].v;
if(e[i].cap>e[i].flow && dis[v]>dis[u]+e[i].cost)
{
dis[v]=dis[u]+e[i].cost;
f[v]=min(f[u],e[i].cap-e[i].flow);
pre[v]=i;
if(!vis[v])
{
vis[v]=;
q.push(v);
}
}
}
}
if(dis[t]==inf) return ;
cost+=dis[t]*f[t];
flow+=f[t];
for(int u=t; u!=s; u=e[pre[u]].u)
{
e[pre[u]].flow+=f[t];
e[pre[u]^].flow-=f[t];
}
return ;
}
int minCost(int s,int t)
{
int cost=,flow=;
while(spfa(s,t,cost,flow)) ;
return cost;
}
} p;
struct record
{
int s,t,w,id;
} mov[maxn]; int main()
{
//scanf("%d",&T);
for(scanf("%d",&T);T;T--)
{
p.init();
scanf("%d %d %d %d",&n,&m,&k,&w);
for (int i=; i<=m; i++)
{
scanf("%d %d %d %d",&mov[i].s,&mov[i].t,&mov[i].w,&mov[i].id);
}
int s=,t=*m+;
p.add(,*m+,,k);
for(int i=; i<=m; i++)
{
p.add(m+m+,i,,);
p.add(i,m+i,-mov[i].w,);
p.add(m+i,t,,);
for(int j=; j<=m; j++)
{
if(i==j) continue;
if(mov[i].t<=mov[j].s)
{
if(mov[i].id==mov[j].id) p.add(i+m,j,w,);
else p.add(i+m,j,,);
}
}
}
printf("%d\n",-p.minCost(s,t));
}
return ;
}

不知道为什么s,t不能定义为全局变量!

 

Videos的更多相关文章

  1. Pexels Videos – 可以免费商业使用的短视频

    Pexels 是一个巨大的平台,提供免费的精美照片,很多设计师和博客每天用它来寻找他们的个人和商业项目的照片.现在我们想介绍 Pexels 视频,他是用来帮助你找到免费的视频.所有的 Pexels 视 ...

  2. How to Create Mixed Reality Videos for the Vive - with Two Controllers

    http://secondreality.co.uk/blog/how-to-create-mixed-reality-videos-for-the-vive-with-two-controllers ...

  3. ###《High-level event recognition in unconstrained videos》

    Author: Yu-Gang Jiang, Shih-Fu Chang 事件检测的目标就是自动识别给定视频序列中的感兴趣事件.进行视频事件检测通常很困难,特别是在网络中非限制的视频.在非限制情况下, ...

  4. 201904:Action recognition based on 2D skeletons extracted from RGB videos

    论文标题:Action recognition based on 2D skeletons extracted from RGB videos 发表时间:02 April 2019 解决问题/主要思想 ...

  5. 【ML】Two-Stream Convolutional Networks for Action Recognition in Videos

    Two-Stream Convolutional Networks for Action Recognition in Videos & Towards Good Practices for ...

  6. 【CV】ICCV2015_Describing Videos by Exploiting Temporal Structure

    Describing Videos by Exploiting Temporal Structure Note here: it's a learning note on the topic of v ...

  7. 【CV】ICCV2015_Unsupervised Learning of Visual Representations using Videos

    Unsupervised Learning of Visual Representations using Videos Note here: it's a learning note on Prof ...

  8. 论文阅读:Videos as Space-Time Region Graphs

    Videos as Space-Time Region Graphs ECCV 2018 Xiaolong Wang 2018-08-03 11:16:01 Paper:arXiv 本文利用视频中时空 ...

  9. 论文阅读: End-to-end Learning of Action Detection from Frame Glimpses in Videos

      End-to-End Learning of Action Detection from Frame Glimpses in Videos  CVPR 2016  Motivation:    本 ...

  10. Deep Reinforcement Learning for Visual Object Tracking in Videos 论文笔记

    Deep Reinforcement Learning for Visual Object Tracking in Videos 论文笔记 arXiv 摘要:本文提出了一种 DRL 算法进行单目标跟踪 ...

随机推荐

  1. hdu 1847 Good Luck in CET-4 Everybody!(巴什博弈)

    Good Luck in CET-4 Everybody! HDU - 1847 大学英语四级考试就要来临了,你是不是在紧张的复习?也许紧张得连短学期的ACM都没工夫练习了,反正我知道的Kiki和Ci ...

  2. 洛谷P2915 [USACO08NOV]奶牛混合起来Mixed Up Cows

    P2915 [USACO08NOV]奶牛混合起来Mixed Up Cows 题目描述 Each of Farmer John's N (4 <= N <= 16) cows has a u ...

  3. 洛谷P3527 [POI2011]MET-Meteors(整体二分)

    传送门 整体二分 先二分一个答案,判断是否可行,把可行的全都扔到左边,不可行的扔到右边 判断是否可行用树状数组就行 具体细节看代码好了 整体二分细节真多……也可能是我大脑已经退化了? //minamo ...

  4. Maven整合Eclipse进行Java项目开发

    一.Maven的配置 ①要求当前系统环境下配置了JAVA_HOME 在CMD命令行中输入:echo %JAVA_HOME% 如果能出来JDK的安装目录,说明我们配置了JAVA环境 ②将Maven的ZI ...

  5. IDEA的git密码修改

    问题: 如果你办公的电脑是同事用过,在每次提交git的时候都显示是他的名字.想要修改提交git用户名密码. 但是博客idea 修改Git密码和账号方法所示方法无效.且操作系统是win10.(其他操作系 ...

  6. vue 中的.sync语法糖

    提到父子组件相互通信,可能大家的第一反应是$emit,最近在学着封装组件,以前都是用的别人封装好的UI组件,对vue中的.sync这个修饰符有很大的忽略,后来发现这个修饰符很nice,官方对她的描述是 ...

  7. GUI的最终选择 Tkinter(一):Tkinter最初体验

    EasyGui就是一个简单的文字交互界面模块,从今天开始来开始学习Tkinter Tkinter是Python标准的Gui库,它实际是建立在Tk技术上的,Tk最初是为Tcl(一门工具名语言)所涉及的, ...

  8. linux读取yaml文件的某个属性值

    trigger=$(cat test.yaml | grep "trigger" | awk '{print $2}') 该条命令的意思是:读取test.yaml文件中的trigg ...

  9. Unity MonoBehaviour.Invoke 调用

    使用 Invoke() 方法需要注意 3点: 1 :它应该在 脚本的生命周期里的(Start.Update.OnGUI.FixedUpdate.LateUpdate)中被调用: 2:Invoke(); ...

  10. 【Linux】Linux查看程序端口占用情况

    使用命令查询8880端口的占用信息: netstat -naop|grep 查询结果: 发现8880端口被PID为4518的进程占用 使用命令查询所有的进程和端口使用情况: netstat –apn ...