A1107. Schedule time limit: 1.0s memory limit: 256.0MB Total commits: 388 AC: 179 average score: 57.73 share the subject to: View unformatted questions submit questions source N OIP1996 Raise group Problem description There are 2 N (n<=6) teams in a single cycle, scheduled to be completed within 2 n–1 days, and each team play a game every day. Design a match arrangement so that each team will compete with different opponents within 2 n–1 days.
For example, the match arrangement at n=2:
Team 1 2 3 4
Race 1==2 3==4 Day
1==3 2==4 two days
1==4 2==3 Three day input format the first line of input contains an integer n. Output format output 2^n-1 lines, each line beginning with a pair of angle brackets, inside the output number of days. Then write out the arrangements for the day. The detailed format is shown in the sample. There are several scenarios that output the smallest dictionary order. Sample input 2 sample output <1>1-2,3-4
<2>1-3,2-4
<3>1-4,2-3 data size and conventions n<=6
Parsing: Hash of the weight.
Use B[i][j] to record whether I and J have played, total N teams.
Although not mentioned in the title, the output should be output in dictionary order.
Code:
#include <cstdio>
#include <cstring>
#define MAXN
using namespace std;
BOOL A[MAXN],B[MAXN][MAXN];
int main ()
{
int n,i,j,k,s,sum;
scanf ("%d", &n);
s=1<<n;
for (i=1;i<s;i++)
{
memset (a,0,sizeof (a));
printf ("<%d>", I);
sum=0;
for (j=1;j<s;j++) for
(k=j+1;k<=s;k++)
if (!a[j] &&!a[k] &&!b[j][k] &&!b[k][ J])
{
a[j]=a[k]=1;
b[j][k]=b[k][j]=1,sum++;
printf ("%d-%d", j,k);
if (sum< (s>>1)) printf ("");
}
printf ("\ n");
}
return 0;
}