CF803A.Maximal Binary Matrix

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given matrix with n rows and n columns filled with zeroes. You should put k ones in it in such a way that the resulting matrix is symmetrical with respect to the main diagonal (the diagonal that goes from the top left to the bottom right corner) and is lexicographically maximal.

One matrix is lexicographically greater than the other if the first different number in the first different row from the top in the first matrix is greater than the corresponding number in the second one.

If there exists no such matrix then output -1.

给你一个 nn 行 nn 列的矩阵,初始时所有元素均为 00。你需要在其中放置 kk 个 11,使得最终得到的矩阵关于主对角线(即从左上角到右下角的对角线)对称,且字典序最大。

若矩阵 AA 的字典序大于矩阵 BB,则定义为:从上到下逐行比较两个矩阵,在第一个存在差异的行中,第一个不同的数在 AA 中大于 BB 中对应位置的数。

如果不存在满足条件的矩阵,则输出 −1-1。

输入格式

The first line consists of two numbers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 106).

第一行包含两个数字 nn 和 kk(1 ≤ n ≤ 1001 ≤ n ≤ 100,0 ≤ k ≤ 1060 ≤ k ≤ 10^6)。

输出格式

If the answer exists then output resulting matrix. Otherwise output -1.

如果答案存在,则输出结果矩阵;否则输出 −1-1。

输入输出样例

  • 输入#1

    2 1

    输出#1

    1 0 
    0 0
  • 输入#2

    3 2

    输出#2

    1 0 0 
    0 1 0 
    0 0 0
  • 输入#3

    2 5

    输出#3

    -1

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

首页