题意:n支队伍打比赛,每2队只进行1场比赛,规定时间内胜得3分,败得0分,若是打到了加时赛,那么胜得2分,败得1分,给出n支队伍最后的总得分,问这个结果是否是可能的,是的话输出“CORRECT”及各场比赛各队伍的比分情况,否则输出"INCORRECT"(2 <= n <= 200)。

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1736

——>>赛后师弟说这是一道网络流大水题,果如其言~

设一个超级源点s,一个超级汇点t,各支队伍各为1个结点,各场比赛也各为1个结点,从s到各场比赛各连1条边,容量为3,从各场比赛到这场比赛的2支参赛队伍各连1条边,容量为3,最后从各支队伍向t各连1条边,容量为输入的对应得分。然后,跑一次最大流,若最大流为满流3 * n * (n-1) / 2,则得分是正确的,再根据各场比赛的流量输出相应的数据,否则得分是不正确的。

#include <cstdio>
#include <cstring>
#include <vector>
#include <queue> using namespace std; const int maxv = 200 + 10;
const int maxn = 40000 + 10;
const int INF = 0x3f3f3f3f; int a[maxv], vs[maxv][maxv]; struct Edge{
int u;
int v;
int cap;
int flow;
}; struct Dinic{
int n, m, s, t;
vector<Edge> edges;
vector<int> G[maxn];
bool vis[maxn];
int d[maxn];
int cur[maxn]; int addEdge(int uu, int vv, int cap){
edges.push_back((Edge){uu, vv, cap, 0});
edges.push_back((Edge){vv, uu, 0, 0});
m = edges.size();
G[uu].push_back(m-2);
G[vv].push_back(m-1);
return m-2;
} bool bfs(){
memset(vis, 0, sizeof(vis));
queue<int> qu;
qu.push(s);
d[s] = 0;
vis[s] = 1;
while(!qu.empty()){
int x = qu.front(); qu.pop();
int si = G[x].size();
for(int i = 0; i < si; i++){
Edge& e = edges[G[x][i]];
if(!vis[e.v] && e.cap > e.flow){
vis[e.v] = 1;
d[e.v] = d[x] + 1;
qu.push(e.v);
}
}
}
return vis[t];
} int dfs(int x, int a){
if(x == t || a == 0) return a;
int flow = 0, f;
int si = G[x].size();
for(int& i = cur[x]; i < si; i++){
Edge& e = edges[G[x][i]];
if(d[x] + 1 == d[e.v] && (f = dfs(e.v, min(a, e.cap-e.flow))) > 0){
e.flow += f;
edges[G[x][i]^1].flow -= f;
flow += f;
a -= f;
if(a == 0) break;
}
}
return flow;
} int Maxflow(int s, int t){
this->s = s;
this->t = t;
int flow = 0;
while(bfs()){
memset(cur, 0, sizeof(cur));
flow += dfs(s, INF);
}
return flow;
}
}; int main()
{
int n;
while(scanf("%d", &n) == 1){
Dinic din;
int t = n + n * (n-1) / 2 + 1;
for(int i = 1; i <= n; i++){
scanf("%d", &a[i]);
din.addEdge(i, t, a[i]);
}
for(int i = 1, k = n+1; i <= n; i++)
for(int j = i+1; j <= n; j++, k++){
vs[i][j] = din.addEdge(0, k, 3);
din.addEdge(k, i, 3);
din.addEdge(k, j, 3);
}
if(din.Maxflow(0, t) == 3 * n * (n-1) / 2){
puts("CORRECT");
for(int i = 1; i <= n; i++)
for(int j = i+1; j <= n; j++){
int L = din.edges[vs[i][j]+2].flow;
int R = din.edges[vs[i][j]+4].flow;
if(L == 3 && R == 0) printf("%d > %d\n", i, j);
else if(L == 0 && R == 3) printf("%d < %d\n", i, j);
else if(L == 2 && R == 1) printf("%d >= %d\n", i, j);
else printf("%d <= %d\n", i, j);
}
}
else puts("INCORRECT");
}
return 0;
}

URAL - 1736 - Chinese Hockey的更多相关文章

  1. URAL 1736 Chinese Hockey(网络最大流)

    Description Sergey and Denis closely followed the Chinese Football Championship, which has just come ...

  2. URAL 1736 Chinese Hockey 网络流+建图

    题目链接:点击打开链接 题意: 给定n个队伍的得分情况,输出随意一个可行解. n个队伍随意2个队伍 a, b 间有且仅有一场比赛. 比赛结果分4种: 1.a +3, b +0 2.a +0, b +3 ...

  3. 使用MySQL数据库将汉字转换成拼音的一个C语言小程序

    环境: mysql:mysql-5.1.65 centos:centos 6.5 编译命令: gcc -o chinesetopinyin chinesetopinyin.c -L/usr/lib/m ...

  4. URAL 1962 In Chinese Restaurant 数学

    In Chinese Restaurant 题目连接: http://acm.hust.edu.cn/vjudge/contest/123332#problem/B Description When ...

  5. URAL 1873. GOV Chronicles

    唔 神题一道 大家感受一下 1873. GOV Chronicles Time limit: 0.5 secondMemory limit: 64 MB A chilly autumn night. ...

  6. CTRL-Space always toggles Chinese IME (Windows 7、10)

    一.window占用了ctrl+空格的快捷键,影响开发工具的只能提示的使用. 二.解决方式: Go to Start > Type in regedit and start it (打开运行输入 ...

  7. OpenCascade Chinese Text Rendering

    OpenCascade Chinese Text Rendering eryar@163.com Abstract. OpenCascade uses advanced text rendering ...

  8. NetSuite Chinese Finance Reports

    NetSuite has a strong report customization application. The standard finance reports has a different ...

  9. Chinese economic influence in North Korea

    Where this new investment is being targeted is also interesting雄性禿 . "If you look at the econom ...

随机推荐

  1. HDU - 3594 Cactus

    这是一个有向仙人掌的题目,要求判定给定的图是不是强连通图,而且每一条边只能出现在一个环中,这里有一个介绍有向仙人掌的文档:http://files.cnblogs.com/ambition/cactu ...

  2. LINQ TO SQL 怎样 执行存储过程并返回存储过程的临时表

    查了GOOGLE一下,这种办法可以解决 我的存储过程是这样的: CREATE procedure cal_month_dep_fast  @begdt datetime,@endt datetime ...

  3. C语言考试解答十题

    学院比较奇葩,大一下期让学的VB,这学期就要学C++了,然后在开学的前三个周没有课,就由老师讲三个周的C语言,每天9:30~11:30听课,除去放假和双休日,实际听课时间一共是12天*2小时,下午是1 ...

  4. php Magic methods __call

    <?php class Car{ protected $_color; protected $_model; public function __call($name,$arguments){ ...

  5. jstring 和char 之间的转换方法

    //jstring to char* char* jstringTostring(JNIEnv* env, jstring jstr) { char* rtn = NULL; jclass clsst ...

  6. IPv6 tutorial 3 New features: IPsec and LAN features

    https://4sysops.com/archives/ipv6-tutorial-part-3-new-features-ipsec-and-lan-features/ In the last p ...

  7. [HDU 5029] Relief grain

    Relief grain Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 100000/100000 K (Java/Others)T ...

  8. keychain中我的证书与证书, p12与pem, apns, 推送

    如果在A电脑上生成 的apns, 到B电脑上导入此文件时, 在 "我的证书"中找不到, 要去"证书"才能找到, 因为 创建时的csr不是本机生成的. 那这样的话 ...

  9. GPIO

    一.什么是GPIO?       首先应该理解什么是GPIO.GPIO,英文全称为General-Purpose IO ports,也就是通用IO口.在嵌入式系统中常常有数量众多,但是结构却比较简单的 ...

  10. How to detect and avoid memory and resources leaks in .NET applications

    By Fabrice Marguerie Despite what a lot of people believe, it's easy to introduce memory and resourc ...