提出 #50322419


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;

int N, M, A[191], B[191], r[21][21], p[21][21];

int main() {
	// 入力を受け取る
	int N;
	cin >> N;
	int M = N * (N - 1) / 2;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
	}

	// 各点対が何番目に遠いかを求める
	for (int i = 1; i <= M; i++) {
		r[A[i]][B[i]] = M - i + 1;
	}

	// 点の座標を求める
	int L = 100'000'000;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (i > j) p[i][j] = 0;
			if (i == j) p[i][j] = L;
			if (i < j) p[i][j] = r[i][j];
		}
	}
	
	// 出力する
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			cout << p[i][j];
			if (j != N) cout << ' ';
			if (j == N) cout << endl;
		}
	}

	return 0;
}

提出情報

提出日時
問題 D - Distance Ranking
ユーザ square1001
言語 C++ 20 (gcc 12.2)
得点 700
コード長 785 Byte
結果 AC
実行時間 1 ms
メモリ 3608 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 700 / 700
結果
AC × 1
AC × 10
セット名 テストケース
Sample sample-01.txt
All in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, sample-01.txt
ケース名 結果 実行時間 メモリ
in01.txt AC 1 ms 3460 KiB
in02.txt AC 1 ms 3460 KiB
in03.txt AC 1 ms 3512 KiB
in04.txt AC 1 ms 3508 KiB
in05.txt AC 1 ms 3568 KiB
in06.txt AC 1 ms 3396 KiB
in07.txt AC 1 ms 3468 KiB
in08.txt AC 1 ms 3456 KiB
in09.txt AC 1 ms 3396 KiB
sample-01.txt AC 1 ms 3608 KiB