Problem 2232 炉石传说

不知道fzu的账号在哪里弄,想要做题的可以到vj上面去做 https://vjudge.net/problem/FZU-2232

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
const int maxn = , inf = 0x3f3f3f;
struct Edge {
int from, to, cap, flow;
};
struct Dinic {
int n, m, s, t;
vector<Edge> edges;
vector<int> G[maxn];
bool vis[maxn];
int d[maxn];
int cur[maxn]; void init(int n) {
this->n = n;
for (int i = ; i <= n; ++i) {
G[i].clear();
}
edges.clear();
}
void AddEdge(int from, int to, int cap) {
edges.push_back((Edge){from, to, cap, });
edges.push_back((Edge){to, from, , });
m = edges.size();
G[from].push_back(m-);
G[to].push_back(m-);
}
bool bfs() {
memset(vis, , sizeof(vis));
queue<int> que;
que.push(s);
d[s] = ;
vis[s] = true;
while (!que.empty()) {
int x = que.front(); que.pop();
for (int i = ; i < G[x].size(); ++i) {
Edge& e = edges[G[x][i]];
if (!vis[e.to] && e.cap > e.flow) {
vis[e.to] = true;
d[e.to] = d[x] + ;
que.push(e.to);
}
}
}
return vis[t];
}
int dfs(int x, int a) {
if (x == t || a == ) return a;
int flow = , f;
for (int& i = cur[x]; i < G[x].size(); ++i) {
Edge& e = edges[G[x][i]];
if (d[x] + == d[e.to] && (f = dfs(e.to, min(a, e.cap-e.flow))) > ) {
e.flow += f;
edges[G[x][i]^].flow -= f;
flow += f;
a -= f;
if (a == ) break;
}
}
return flow;
}
int maxflow(int s, int t) {
this->s = s; this->t = t;
int flow = ;
while (bfs()) {
memset(cur,,sizeof(cur));
flow += dfs(s,inf);
}
return flow;
}
}dinic;
int a[maxn], b[maxn], c[maxn], d[maxn];
int main() {
int T; scanf("%d",&T);
while (T--) {
int n; scanf("%d",&n);
int s = n+n+, t = n+n+;
dinic.init(n*+);
for (int i = ; i <= n; ++i) {
scanf("%d%d",&a[i],&b[i]);
dinic.AddEdge(s,i,);
}
for (int i = ; i <= n; ++i) {
scanf("%d%d",&c[i],&d[i]);
dinic.AddEdge(i+n,t,);
for (int j = ; j <= n; ++j) {
if (b[j] >= c[i] && a[j] > d[i]) {
dinic.AddEdge(j,i+n,);
}
}
} int ans = dinic.maxflow(s,t);
printf("%s\n",ans==n ? "Yes" : "No");
}
return ;
}

Problem 2232 炉石传说的更多相关文章

  1. fzu Problem - 2232 炉石传说(二分匹配)

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=2232 Description GG学长虽然并不打炉石传说,但是由于题面需要他便学会了打炉石传说.但是传统的炉石 ...

  2. 炉石传说__multiset

     炉石传说  Problem Description GG学长虽然并不打炉石传说,但是由于题面需要他便学会了打炉石传说.但是传统的炉石传说对于刚入门的GG学长来说有点复杂,所以他决定自己开发一个简化版 ...

  3. [原创]webapp/css3实战,制作一个《炉石传说》宣传页

    在移动网页,尤其是webapp中常需要用到大量的css3动画,来获得良好交互体验 我之前帮朋友做了一个,可惜没帮上忙现在和大家分享一下 目标是要做一个<炉石传说>游戏的介绍宣传页面,文字内 ...

  4. 炉石传说 C# 开发笔记(6月底小结)

    炉石传说的开发,已经有30个工作日了. 关于法术的定义方法,有过一次重大的变更:法术效果是整个炉石的核心,正是因为丰富的法术效果,才造就了炉石的可玩性. 原来构思的时候,对于法术效果没有充分的理解,所 ...

  5. 炉石传说 C# 开发笔记 (续)

    炉石传说山寨的工作一直在进行着,在开发过程中深深体会到,对于业务的理解和整个程序的架构的整理远比开发难得多. 在开发过程中,如果你的模型不合理,不准确,很有可能造成代码的混乱,冗余,难以维护和扩展性比 ...

  6. 炉石传说 C# 开发笔记

    最近在大连的同事强力推荐我玩 炉石传说,一个卡牌游戏.加上五一放一个很长很长的假期,为了磨练自己,决定尝试开发一个C#的炉石传说. 这件事情有人已经干过了,开发了一个网页版的炉石,但是貌似不能玩... ...

  7. 《炉石传说》建筑设计欣赏(6):卡&amp;在执行数据时,组织能力

    上一篇文章我们看到了<炉石传说>核心存储卡的数据,今天,我们不断探索卡&身手. 基本的类 通过之前的分析,卡牌&技能涉及到几个类体系:Entity.Actor.Card.S ...

  8. islands打炉石传说<DP>

    islands最近在完一款游戏"炉石传说",又名"魔兽英雄传".炉石传说是一款卡牌类对战的游戏.游戏是2人对战,总的来说,里面的卡牌分成2类,一类是法术牌,另一 ...

  9. CCF2016093炉石传说(C语言版)

    问题描述 <炉石传说:魔兽英雄传>(Hearthstone: Heroes of Warcraft,简称炉石传说)是暴雪娱乐开发的一款集换式卡牌游戏(如下图所示).游戏在一个战斗棋盘上进行 ...

随机推荐

  1. php +go关键字实现协程

    来源: https://studygolang.com/articles/17631?fr=sidebar 今天在知乎浏览时忽然发现了一个有趣的东西,php竟然可以实现协程的实现,而且还是通过go关键 ...

  2. Libra教程之:数据结构和存储

    文章目录 存储的数据结构 账本历史 账本状态 账户 事件 前面的文章我们知道,libra会把所有的数据都存储在账本中.为了方便业务逻辑和数据的校验,这个存储是以特定的数据结构来实现的,这里我们叫做验证 ...

  3. 学会HTML就可以找工作了

    对编程小白来讲,想要学习门槛低,学习周期短,难度指数可忽略.短时间内可能找一份薪资不错编程相关工作,那就把HTML作为入门级语言吧. 网页设计师 (//upload-images.jianshu.io ...

  4. Apache Storm 官方文档 —— Storm 与 Kestrel

    本文说明了如何使用 Storm 从 Kestrel 集群中消费数据. 前言 Storm 本教程中使用了 storm-kestrel 项目和 storm-starter 项目中的例子.建议读者将这几个项 ...

  5. Java pdf转高清图片

    为什么80%的码农都做不了架构师?>>>   package com.hyb.kai.web.controller; import java.awt.image.BufferedIm ...

  6. POJ 2136 Vertical Histogram(当时写的比较恶心,优化一下)

    Vertical Histogram Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21223 Accepted: 10048 ...

  7. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 D Carneginon

    Carneginon was a chic bard. But when he was young, he was frivolous and had joined many gangs. Recen ...

  8. muduo网络库源码学习————线程安全

    线程安全使用单例模式,保证了每次只创建单个对象,代码如下: Singleton.h // Use of this source code is governed by a BSD-style lice ...

  9. 0x01-Linux常用文件处理命令

    0x01-Linux常用文件处理命令 摘要 文件可以说是占据了Linux系统半壁江山,那么,我们理所应当要认识文件,且还要懂得如何创建.查看文件(touch.cat命令).既然是使用Linux,当然是 ...

  10. FastDFS文件服务器安装指南附安装包和自启动(看此篇就够了)

    安装包在最后,本文为博主自己亲自安装记录 转载请注明出处 注意文字不清晰请放大看,放大看!! 安装包地址