Description

Sergey and Denis closely followed the Chinese Football Championship, which has just come to an end. They supported the Katraps andKomolotiv teams, but, unfortunately, these teams tied for last place in the championship. Sergey was so disappointed that he suggested Denis that they change to hockey fans.
There are n teams competing in the Chinese Ice Hockey Championship. During the season, each team must play with each other team exactly one game. If a team wins in the regulation time, it gets 3 points and the losing team gets 0 points. If the regulation time is ended in a draw, then the overtime is played. The team that wins in the overtime gets 2 points and the team that loses gets 1 point. A game can't end in a draw in ice hockey.
Denis wants to determine which team he will support. In order to make the choice, he has found a table on the Web in which it is shown for each team how many points it scored in the last year's season. Sergey suspects that there is a mistake in this table because no all-play-all tournament could end with such results. Is Sergey right?

Input

The first line contains the integer n (2 ≤ n ≤ 200). The second line contains n space-separated non-negative integers; they are the scores of the teams in the previous championship. The scores are given in the non-increasing order. The sum of all the scores is 3n(n–1)/2. None of the teams scored more than 3(n–1) points.

Output

If Sergey is right and there is a mistake in the table, output “INCORRECT” in the only line. Otherwise, in the first line output “CORRECT” and in the following n(n–1)/2 lines output the results of the games. Each result must have the form “i ? j”, where i and j are the numbers of the teams that played the game and ? can be <<=>=, or >, which means that the first team lost in the regulation time, lost in the overtime, won in the overtime, and won in the regulation time, respectively. The teams are numbered from 1 to n in the order in which they are given in the input.

题目大意:有n支队,每两队之间进行一场比赛,胜者得3分,败者0分。若为加时赛胜利者2分,败者1分。现在给所有队伍比完赛的得分,问有没有可能构造出这个得分,并输出得到这个得分的每一场比赛的结果。

思路:构建网络流。新开源点S汇点T,从源点到每一场比赛连一条容量为3的边,从每一场比赛到这场比赛的双方连一条边,容量为无穷大(大于等于3就行),从每一支队到汇点连一条边,容量为这个队伍的最终得分。若满流,则有解。每场比赛到比赛双方的边的流量,就是这场比赛某方的得分。

代码(31MS):

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std; const int MAXN = * ;
const int MAXE = MAXN * ;
const int INF = 0x3fff3fff; struct SAP {
int head[MAXN], pre[MAXN], dis[MAXN], cur[MAXN], gap[MAXN];
int next[MAXE], to[MAXE], cap[MAXE], flow[MAXE];
int n, ecnt, st, ed; void init() {
memset(head, , sizeof(head));
ecnt = ;
} void add_edge(int u, int v, int c) {
to[ecnt] = v; cap[ecnt] = c; flow[ecnt] = ; next[ecnt] = head[u]; head[u] = ecnt++;
to[ecnt] = u; cap[ecnt] = ; flow[ecnt] = ; next[ecnt] = head[v]; head[v] = ecnt++;
} void bfs() {
memset(dis, 0x3f, sizeof(dis));
queue<int> que; que.push(ed);
dis[ed] = ;
while(!que.empty()) {
int u = que.front(); que.pop();
++gap[dis[u]];
for(int p = head[u]; p; p = next[p]) {
int &v = to[p];
if(cap[p ^ ] && dis[v] > n) {
dis[v] = dis[u] + ;
que.push(v);
}
}
}
} int Max_flow(int ss, int tt, int nn) {
st = ss, ed = tt, n = nn;
int ans = , minFlow = INF, u;
for(int i = ; i <= n; ++i) {
cur[i] = head[i];
gap[i] = ;
}
bfs();
u = pre[st] = st;
while(dis[st] < n) {
bool flag = false;
for(int &p = cur[u]; p; p = next[p]) {
int &v = to[p];
if(cap[p] > flow[p] && dis[u] == dis[v] + ) {
flag = true;
minFlow = min(minFlow, cap[p] - flow[p]);
pre[v] = u;
u = v;
if(u == ed) {
ans += minFlow;
while(u != st) {
u = pre[u];
flow[cur[u]] += minFlow;
flow[cur[u] ^ ] -= minFlow;
}
minFlow = INF;
}
break;
}
}
if(flag) continue;
int minDis = n - ;
for(int p = head[u]; p; p = next[p]) {
int &v = to[p];
if(cap[p] > flow[p] && dis[v] < minDis) {
minDis = dis[v];
cur[u] = p;
}
}
if(--gap[dis[u]] == ) break;
++gap[dis[u] = minDis + ];
u = pre[u];
}
return ans;
}
} G; int n, a[];
int game_id[][]; int main() {
scanf("%d", &n);
for(int i = ; i <= n; ++i) scanf("%d", &a[i]);
G.init();
int ss = n + n * (n - ) / + , tt = ss + ;
int cnt = n + ;
for(int i = ; i <= n; ++i) {
G.add_edge(i, tt, a[i]);
for(int j = i + ; j <= n; ++j) {
game_id[i][j] = G.ecnt;
G.add_edge(cnt, i, );
G.add_edge(cnt, j, );
G.add_edge(ss, cnt, );
++cnt;
}
}
if(G.Max_flow(ss, tt, tt) != * n * (n - ) / ) puts("INCORRECT");
else {
puts("CORRECT");
for(int i = ; i <= n; ++i) {
for(int j = i + ; j <= n; ++j) {
switch(G.flow[game_id[i][j]]) {
case :printf("%d < %d\n", i, j);break;
case :printf("%d <= %d\n", i, j);break;
case :printf("%d >= %d\n", i, j);break;
case :printf("%d > %d\n", i, j);break;
}
}
}
}
}

最新文章

  1. 代码批量生成WORD的遇到的问题及解决
  2. background-image小解
  3. Mysql数据库登录问题:Your password has expired.
  4. Java Day 05
  5. 《Python CookBook2》 第一章 文本 - 测试一个对象是否是类字符串 &amp;&amp; 字符串对齐
  6. 如何给网页标题栏上添加图标(favicon.ico)
  7. Altium Designer中Via过孔设置
  8. 如何将Java Web项目部署到服务器上
  9. highcharts的使用
  10. Vue.js实现拼图游戏
  11. VMware虚拟机中调整Linux分区大小手记(转发)
  12. 运行容器的最佳实践 - 每天5分钟玩转 Docker 容器技术(24)
  13. UIScrollerview的contentsize设置
  14. ZooKeeper的安装
  15. mlp_clf_mnist_test
  16. saltstack API(一) 安装并测试
  17. redis+mysql
  18. int和Integer有什么区别?
  19. ado_基本连接操作【四】
  20. POJ 1836

热门文章

  1. 在cmd下面执行.py文件时提示ModuleNotFoundError 但是 IDE 不报错
  2. 简单使用PuTTy登录centos虚拟机
  3. checkbox的第三种状态--不确定状态
  4. Linux系统文件和目录的属性及权限
  5. 【vlan-给予mac地址认证】
  6. 五、RegExp(正则表达式)篇
  7. jQuery(二)事件
  8. 类的特殊方法&quot;__new__&quot;详解
  9. laravel路由组+中间件
  10. Python学习 :六个标准数据类型