結果

問題 No.1087 転倒数の転倒数
ユーザー QCFiumQCFium
提出日時 2020-05-19 18:29:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 602 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 164,264 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 19:50:01
合計ジャッジ時間 10,448 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 RE -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 2 ms
5,376 KB
testcase_10 RE -
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 87 ms
5,376 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 85 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 68 ms
5,376 KB
testcase_26 AC 58 ms
5,376 KB
testcase_27 AC 38 ms
5,376 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 25 ms
5,376 KB
testcase_31 RE -
testcase_32 AC 68 ms
5,376 KB
testcase_33 AC 40 ms
5,376 KB
testcase_34 RE -
testcase_35 AC 86 ms
5,376 KB
testcase_36 AC 87 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int k = ri();
	if (k > n * (n - 1) * 2) {
		puts("No");
		return 0;
	}
	assert((k & 1) == 0);
	k /= 2;
	int a[n];
	std::iota(a, a + n, 0);
	int cur = n - 1, cnt = 0;
	while (k && k >= cur) {
		k -= cur;
		cur--, cnt++;
	}
	std::rotate(a, a + cnt, a + n);
	std::reverse(a + n - cnt, a + n);
	if (k) std::rotate(a, a + 1, a + k + 1);
	
	puts("Yes");
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) printf(" ");
			printf("%d", a[i] != j);
		}
		puts("");
	}
	
	return 0;
}
0