Tsinsen A1107 比赛安排

来源:互联网 发布:聚友网络客服电话郑州 编辑:程序博客网 时间:2024/04/25 13:38

http://oj.tsinsen.com/A1107

分析:题目基本一样,小心要求字典序最小,搜索着排就好了。

代码:

#include "bits/stdc++.h"using namespace std;int n, t;bool HasBeat[105][105];int main() {    scanf("%d", &n);    t = (1 << n);    for (int i = 1; i < t; ++i) {        printf("<%d>", i);        bool Skip[105] = { 0 };         for (int k = 1; k < t; ++k) {            if (Skip[k]) continue;            for (int u = k + 1; u <= t; ++u) if (!HasBeat[k][u] && !Skip[u]) {                Skip[u] =  HasBeat[k][u] = true;                if (k > 1) putchar(',');                printf("%d-%d", k, u);                break;            }        }        putchar('\n');    }    return 0;}
1 0
原创粉丝点击