跳到正文

个人记录

Informatics Dream Team Heuristic Contest 001 题解

why110623约 1 分钟
原文

这是 2025年10月20日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2025年1月2日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 1 分钟

版本

  1. v2当前
  2. v1

A

C++
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;

    // 生成比赛日程表
    vector<vector<int>> sch(n, vector<int>(n - 1));
    
    // 进行每一轮比赛
    for (int d = 0; d < n - 1; ++d) {
        for (int i = 0; i < n / 2; ++i) {
            // 计算比赛对手
            int p1 = (i + d) % n + 1;
            int p2 = (n / 2 + i + d) % n + 1;
            
            sch[i][d] = p2;
            sch[n / 2 + i][d] = p1;
        }
    }

    // 输出比赛日程表
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n - 1; ++j) {
            cout << sch[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

A-Final

略