Description

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.

Input

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

Output

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

Examples
input
2 1
output
1 0 
0 0
input
3 2
output
1 0 0 
0 1 0
0 0 0
input
2 5
output
-1
题意:问如何将二进制矩阵排成字典序最大(需要主对角线对称)
解法:当然是这种啦,如果发现还有剩余1就输出-1
1 1 1 1 1 1 1 1 1...
1 1
1 1
1 .
1 .
 #include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=;
int x[][];
int n;
int num;
int main()
{
cin>>n>>num;
for(int i=;num>&&i<=n;i++)
{
x[i][i]=;
num--;
for(int j=i+;num>&&j<=n;j++)
{
x[i][j]=x[j][i]=;
num-=;
}
}
if(num>)
{
cout<<"-1"<<endl;
return ;
}
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
cout<<x[i][j]<<" ";
}
cout<<endl;
}
return ;
}

Educational Codeforces Round 20 A的更多相关文章

  1. Educational Codeforces Round 20

    Educational Codeforces Round 20  A. Maximal Binary Matrix 直接从上到下从左到右填,注意只剩一个要填的位置的情况 view code //#pr ...

  2. Educational Codeforces Round 20 D. Magazine Ad

    The main city magazine offers its readers an opportunity to publish their ads. The format of the ad ...

  3. Educational Codeforces Round 20 C(math)

    題目鏈接: http://codeforces.com/problemset/problem/803/C 題意: 給出兩個數n, k, 將n拆分成k個數的和,要求這k個數是嚴格遞增的,並且這k個數的g ...

  4. Educational Codeforces Round 20.C

    C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  5. Educational Codeforces Round 20 C 数学/贪心/构造

    C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  6. Educational Codeforces Round 20 C. Maximal GCD

    C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  7. Educational Codeforces Round 20 B. Distances to Zero

    B. Distances to Zero time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  8. Educational Codeforces Round 20 A. Maximal Binary Matrix

    A. Maximal Binary Matrix time limit per test 1 second memory limit per test 256 megabytes input stan ...

  9. Educational Codeforces Round 20 E - Roma and Poker(dp)

    传送门 题意 Roma在玩一个游戏,一共玩了n局,赢则bourle+1,输则bourle-1,Roma将会在以下情况中退出 1.他赢了k个bourle 2.他输了k个bourle 现在给出一个字符串 ...

  10. Educational Codeforces Round 20 B

    Description You are given the array of integer numbers a0, a1, ..., an - 1. For each element find th ...

随机推荐

  1. openwrt gstreamer实例学习笔记(五. gstreamer BUS)

    1)概述 BUS(总线) 是一个简单的系统,它采用自己的线程机制将一个管道线程的消息分发到一个应用程序当中.总线的优势是:当使用GStreamer的时候,应用程序不需要线程识别,即便GStreamer ...

  2. jmeter3.0_bodydata中存在中文乱码

    jmeter3.0_bodydata中存在中文乱码 1.进入jmeter.properties配置文件 找到#jsyntaxtextarea.font.family=Hack ,并将“#”取消并重启j ...

  3. nodejs什么值得买自动签到自动评论定时任务

    本项目是基于nodejs开发,实现的功能是,什么值得买自动签到,自动评论功能,自动发邮件,支持多人多账号运行 目的是为了,解放双手,轻松获取什么值得买的经验和积分,得到更高的等级,从而突破很会员等级限 ...

  4. TiDB 是否支持其他存储引擎?

    https://www.pingcap.com/docs-cn/FAQ/ 1.1.11 TiDB 是否支持其他存储引擎? 是的,除了 TiKV 之外,TiDB 还支持一些流行的单机存储引擎,比如 Go ...

  5. 端口扫描 开启 防火墙 iptables SELinux

    Linux 如何打开端口 - lclc - 博客园 https://www.cnblogs.com/lcword/p/5869522.html linux如何查看端口相关信息_百度经验 https:/ ...

  6. HBase运维和优化

    管理工具 HBase ShellHBase Shell是HBase组件提供的基于JRuby IRB的字符界面的交互式客户端程序,通过HBase Shell可以实现对HBase的绝大部分操作 通过hel ...

  7. D. Babaei and Birthday Cake--- Codeforces Round #343 (Div. 2)

    D. Babaei and Birthday Cake time limit per test 2 seconds memory limit per test 256 megabytes input ...

  8. hihocoder 1082 然而沼跃鱼早就看穿了一切 (替换指定的串 )

    #1082 : 然而沼跃鱼早就看穿了一切 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 fjxmlhx每天都在被沼跃鱼刷屏,因此他急切的找到了你希望你写一个程序屏蔽所有句 ...

  9. DedeCms最新文章显示红色日期或加上new字或new小图片

    DedeCMS发布的文章显示红色日期或加上new字或new小图片,给近三天(或当天)发布的文章显示红色日期或加上new字或new小图片等,都是围绕pubdate做文章,写扩展的. 1.红色的日期   ...

  10. codeforces 672B B. Different is Good(水题)

    题目链接: B. Different is Good time limit per test 2 seconds memory limit per test 256 megabytes input s ...