CF42D.Strange town

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Volodya has recently visited a very odd town. There are N tourist attractions in the town and every two of them are connected by a bidirectional road. Each road has some travel price (natural number) assigned to it and all prices are distinct. But the most striking thing about this town is that each city sightseeing tour has the same total price! That is, if we choose any city sightseeing tour — a cycle which visits every attraction exactly once — the sum of the costs of the tour roads is independent of the tour. Volodya is curious if you can find such price system with all road prices not greater than 1000.

沃洛佳最近参观了一座非常奇特的小镇。镇上有 NN 个旅游景点,且任意两个景点之间都由一条双向道路相连。每条道路都标有一个旅行费用(正整数),且所有费用互不相同。但这座小镇最令人震惊的特点是:每条城市观光环线的总费用都相同! 也就是说,如果我们任选一条城市观光环线——即一条恰好访问每个景点一次的环路——那么该环路上所有道路费用之和与所选环线无关。沃洛佳很好奇:你能否构造出这样一种费用分配方案,使得所有道路费用均不超过 10001000

输入格式

Input contains just one natural number (3 ≤ N ≤ 20) — the number of town attractions.

输入仅包含一个自然数(3 ≤ N ≤ 20)——城镇景点的数量。

输出格式

Output should contain N rows containing N positive integer numbers each — the adjacency matrix of the prices graph (thus, j-th number in i-th row should be equal to the price of the road between the j-th and the i-th attraction). Diagonal numbers should be equal to zero. All numbers should not be greater than 1000. All prices should be positive and pairwise distinct. If there are several solutions, output any of them.

输出应包含 N 行,每行包含 N 个正整数——即价格图的邻接矩阵(因此第 i 行第 j 列的数应等于第 j 个景点与第 i 个景点之间道路的价格)。对角线上的元素应为零。所有数字均不得超过 1000。所有价格均为正数且两两互异。若存在多种解,输出任意一种即可。

输入输出样例

  • 输入#1

    3

    输出#1

    0 3 4 
    3 0 5 
    4 5 0

输入解题思路,AI测评打分。不知道怎么写?

首页