In a competition, the winner is scored 3 points and 0 points within the specified time period. In addition, the winner is scored 2 points and the winner is scored 1 point.
Then the League is a single round-robin (compared to any two teams), giving points for each team last season, asking you if this point combination is unreasonable and if it is reasonable, you need to output a plan.
First, we find that the points in a game are fixed, and then three points can correspond to a winning situation no matter how allocated, so we use the maximum stream
Abstract each game and each team into points (point: 1-to 2 * n * (n-1) 2 * n * (n-1) + 1 to 2 * n * (n-1) + n)
Source point and connection capacity for each game 3
Each game is connected to two teams with a capacity of 3
Then, each team is connected to the exchange point. The capacity is the team's points last season.
The maximum stream is used to determine whether the stream is full. If the stream is not full, it is unreasonable.
Otherwise, the output scheme is based on the residual network capacity on the edge.
1736. Chinese hockeytime limit: 1.0 second
Memory limit: 64 mbsergey and Denis closely followed the Chinese football championship, which has just come to an end. They supported
KatrapsAnd
KomolotivTeams, 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
NTeams 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 cocould end with such results. Is Sergey right? Inputthe first line contains the integer
N(2 ≤
N≤ 200). The second line contains
NSpace-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 3
N(
N-1)/2 . None of the teams scored more 3 (
N-1) Points. outputif 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
IAnd
JAre 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
NIn the order in which they are given in the input. Samples
Input |
Output |
48 7 2 1 |
CORRECT2 <= 13 >= 41 > 34 < 21 > 42 > 3 |
48 8 1 1 |
INCORRECT |
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define MAXN 40000#define INF 0xFFFFFFstruct edge{int to,c,next;};edge e[999999];int que[MAXN*100];int dis[MAXN],pre[MAXN];int head[MAXN],head2[MAXN];int st,ed,maxflow;int en,n;void add(int a,int b,int c){e[en].to=b;e[en].c=c;e[en].next=head[a];head[a]=en++;e[en].to=a;e[en].c=0;e[en].next=head[b];head[b]=en++;}bool bfs(){memset(dis,-1,sizeof(dis));que[0]=st,dis[st]=1;int t=1,f=0;while(f<t){int j=que[f++];for(int k=head[j];k!=-1;k=e[k].next){int i=e[k].to;if(dis[i]==-1 && e[k].c){que[t++]=i;dis[i]=dis[j]+1;if(i==ed) return true;}}}return false;}int update(){int p,flow=INF; for (int i=pre[ed];i!=-1;i=pre[i])if(e[head2[i]].c<flow) p=i,flow=e[head2[i]].c; for (int i=pre[ed];i!=-1;i=pre[i])e[head2[i]].c-=flow,e[head2[i]^1].c+=flow; maxflow+=flow; return p;}void dfs(){memset(pre,-1,sizeof(pre));memcpy(head2,head,sizeof(head2)); for(int i=st,j;i!=-1;) { int flag=false; for(int k=head[i];k!=-1;k=e[k].next) if(e[k].c && (dis[j=e[k].to]==dis[i]+1) ) { pre[j]=i;head2[i]=k;i=j;flag=true; if(i==ed)i=update(); if(flag)break; } if (!flag) dis[i]=-1,i=pre[i]; }}int dinic(){maxflow=0;while(bfs())dfs();return maxflow;}int main(){ while(~scanf("%d",&n)) { memset(head,-1,sizeof(head));en=0; int total=n*(n-1)/2+n+1,bas=n*(n-1)/2,cnt=1; st=0,ed=total; for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) { add(cnt,bas+i,3); add(cnt,bas+j,3); cnt++; } for(int i=1;i<=n*(n-1)/2;i++) add(st,i,3); int sum=0;bool ok=1; for(int i=n*(n-1)/2+1;i<=n*(n-1)/2+n;i++) { int tmp; scanf("%d",&tmp); sum+=tmp; if(tmp>3*(n-1)) ok=0; add(i,ed,tmp); } dinic(); if(!ok||sum!=3*n*(n-1)/2||maxflow!=3*n*(n-1)/2) printf("INCORRECT\n"); else { cnt=0; printf("CORRECT\n"); for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) { int si=3-e[cnt].c; int sj=3-e[cnt+2].c; cnt+=4; if(si==3) printf("%d > %d\n",i,j); else if(si==2) printf("%d >= %d\n",i,j); else if(si==0) printf("%d < %d\n",i,j); else if(si==1) printf("%d <= %d\n",i,j); } } } return 0;}