牛客多校第六场 E Androgynos 自补图
题意:
给定点数,构造自补图,要求输出邻接矩阵,和原图与补图的同构映射。
题解:
只有点数为4k和4k+1的情况才能构造自补图,因为只有这些情况下边数才为偶数。
一种构造方式是,邻接矩阵和同构映射增量构造,每次加四个边xyzw,x和w连接原来的所有边,yz不连,同构映射是交换xy,zw
参考:www.matrix67.com/blog/archives/6221
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int M = 2e3 + ;
const LL mod = ;
const LL lINF = 0x3f3f3f3f3f3f3f3f;
bool mp[M][M];
int t;
int n;
int a[M];
int main()
{
scanf("%d", &t);
for (int cnt = ; cnt <= t; cnt++)
{
scanf("%d", &n);
if (n % == )
{
printf("Case #%d: Yes\n", cnt);
memset(mp, , sizeof mp);
mp[][] = mp[][] = ;
mp[][] = mp[][] = ;
mp[][] = mp[][] = ;
a[] = ;
a[] = ;
a[] = ;
a[] = ;
for (int i = ; i <= n; i += )
{
mp[i][i + ] = mp[i + ][i] = ;
mp[i + ][i + ] = mp[i + ][i + ] = ;
mp[i + ][i + ] = mp[i + ][i + ] = ;
for (int j = ; j < ; j+=)
{
for (int k = ; k < i; k++)
{
mp[i + j][k] = mp[k][i + j] = ;
}
}
a[i] = i + ;
a[i + ] = i;
a[i + ] = i + ;
a[i + ] = i + ;
swap(a[i+], a[i + ]);
}
for (int i = ; i <= n; i++)
{
for (int j = ; j <= n; j++)
{
printf("%d", mp[i][j]);
}
puts("");
}
for (int i = ; i < n; i++)
{
printf("%d ", a[i]);
}
printf("%d\n", a[n]);
}
else if (n % == )
{
printf("Case #%d: Yes\n", cnt);
memset(mp, , sizeof mp);
a[] = ;
for (int i = ; i <= n; i += )
{
mp[i][i + ] = mp[i + ][i] = ;
mp[i + ][i + ] = mp[i + ][i + ] = ;
mp[i + ][i + ] = mp[i + ][i + ] = ;
for (int j = ; j < ; j+=)
{
for (int k = ; k < i; k++)
{
mp[i + j][k] = mp[k][i + j] = ;
}
}
a[i] = i + ;
a[i + ] = i;
a[i + ] = i + ;
a[i + ] = i + ;
swap(a[i+], a[i + ]);
}
for (int i = ; i <= n; i++)
{
for (int j = ; j <= n; j++)
{
printf("%d", mp[i][j]);
}
puts("");
}
for (int i = ; i < n; i++)
{
printf("%d ", a[i]);
}
printf("%d\n", a[n]);
}
else
{
printf("Case #%d: No\n", cnt);
}
}
}
牛客多校第六场 E Androgynos 自补图的更多相关文章
- 牛客多校第六场 C Generation I 组合数学 阶乘逆元模板
链接:https://www.nowcoder.com/acm/contest/144/C来源:牛客网 Oak is given N empty and non-repeatable sets whi ...
- 牛客多校第六场 J Heritage of skywalkert 随即互质概率 nth_element(求最大多少项模板)
链接:https://www.nowcoder.com/acm/contest/144/J来源:牛客网 skywalkert, the new legend of Beihang University ...
- 牛客多校第六场-H-Pair
链接:https://ac.nowcoder.com/acm/contest/887/H来源:牛客网 题目描述 Given three integers A, B, C. Count the numb ...
- 同构图+思维构造——牛客多校第六场E
考的其实是同构图的性质: 1.同构图的顶点数,边数相等 2.同构图通过点的映射后邻接矩阵相同 这篇博客讲的很好https://www.jianshu.com/p/c33b5d1b4cd9 本题还需要一 ...
- 2018牛客多校第六场 G.Pikachu
题意: 给出一棵n个点的树,每条边有边权.对这个树加边变成一个完全图.新加的边的权值为边上两点在树上的距离.求完全图上任意两点的最大流之和. 题解: 一共有C(n,2)个点对.假设当前求s到t之间的最 ...
- 2018牛客多校第六场 I.Team Rocket
题意: 给出n个区间和m个点(点按顺序给出且强制在线).每个区间只会被第一个他包含的点摧毁.问每个点能摧毁多少个区间以及每个区间是被哪个点摧毁的. 题解: 将n个区间按照左端点排序,然后用vector ...
- 牛客多校第六场C
一个数很大,并不能预处理,所以要进行公式变换,存前一个的值就好 #include <bits/stdc++.h> using namespace std; typedef long lon ...
- Palindrome Mouse(2019年牛客多校第六场C题+回文树+树状数组)
目录 题目链接 题意 思路 代码 题目链接 传送门 题意 问\(s\)串中所有本质不同的回文子串中有多少对回文子串满足\(a\)是\(b\)的子串. 思路 参考代码:传送门 本质不同的回文子串肯定是要 ...
- 2019牛客多校第六场 B - Shorten IPv6 Address 模拟
B - Shorten IPv6 Address 题意 给你\(128\)位的二进制,转换为十六进制. 每\(4\)位十六进制分为\(1\)组,每两组用一个\(":"\)分开. 每 ...
随机推荐
- Storm设计思想
- day01 python起源 介绍 解释器 变量 流程控制if
day01 python 一.python的起源 1.python简介 java 企业级应用, android, app c 操作系统, 做开发语言的, 游戏的内核 ...
- java创建一个空白zip
String zipath = localpath+zipname+".zip"; public static void createNewzip(String zipath) t ...
- FTT & NTT & 分治FFT
FFT study from: http://www.orchidany.cf/2019/02/19/FFT1/ https://www.cnblogs.com/zwfymqz/p/8244902.h ...
- webpack 配置es6 语法
使用babel来编译es6的语法; 1.在终端上输入指令 npm install webpack babel-loader babel-core babel-preset-es2015 --save- ...
- 大数据学习路线,来qun里分享干货,
一.Linux lucene: 全文检索引擎的架构 solr: 基于lucene的全文搜索服务器,实现了可配置.可扩展并对查询性能进行了优化,并且提供了一个完善的功能管理界面. 推荐一个大数据学习群 ...
- iBatis开发的一个应用
今天开始学习iBatis框架,感觉这个框架很轻巧,方便,使用上手很快,没有多大的难点,下面就介绍一下第一个应用开发的步骤: 第一步:在mysql的test数据库中建立一张表:account creat ...
- NX二次开发-隐藏对象UF_OBJ_set_blank_status
NX9+VS2012 #include <uf.h> #include <uf_curve.h> #include <uf_obj.h> UF_initialize ...
- NX二次开发-NXOPEN创建工程图表格Annotations::TableSectionBuilder *tableSectionBuilder1;
NX9+VS2012 #include <uf.h> #include <uf_tabnot.h> #include <NXOpen/Part.hxx> #incl ...
- Linux下使用Eclipse 远程调试
1 开启端口 修改/apache-tomcat-7.0.40/bin/catalina.sh 在合适的位置(请自行判断,只要有JAVA_OPTS的设定前后即可)插入下面的设定:UI_DEBUG=&qu ...