题意

$m \leqslant 500000$,题目打错了

Sol

神仙题Orz

构造矩阵$B$,使得$B[b[i]][a[i]] = 1$

那么他的行列式的奇偶性也就对应了生成排列数列数量的奇偶性(定义)

删除一个位置相当于去掉对答案的贡献,也就是代数余子式的值

代数余子式可以由伴随矩阵求出$A^{*} = |A| A^{-1}$

这里只需要奇偶性,因此不需要求出实际行列式的值。

矩阵可以用bitset加速,可以过掉这个题

#include<cstdio>
#include<bitset>
#include<iostream>
using namespace std;
const int MAXN = ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N, M;
bitset<MAXN * + > b[MAXN];
int x[], y[];
int main() {
N = read(); M = read();
for(int i = ; i <= N; i++) b[i][i + N] = ;
for(int i = ; i <= M; i++) {
x[i] = read(), y[i] = read();
b[x[i]][y[i]] = ;
}
for(int i = , j; i <= N; i++) {
for(j = i; j <= N; j++) if(b[j][i]) {swap(b[i], b[j]); break;}
for(int k = ; k <= N; k++)
if(b[k][i] && (k != i)) b[k] ^= b[i];
}
for(int i = ; i <= N; i++, puts(""))
for(int j = ; j <= * N; j++)
cout << b[i][j] << " ";
return ;
}
/*
3 7
1 1
1 3
2 2
2 3
3 1
3 2
3 3 */

codeforces736D. Permutations(线性代数)的更多相关文章

  1. 【CF736D】Permutations 线性代数+高斯消元

    [CF736D]Permutations 题意:有一个未知长度为n的排列和m个条件,第i个条件$(a_i,b_i)$表示第$a_i$个位置上的数可以为$b_i$.保证最终合法的排列的个数是奇数.现在有 ...

  2. 【线性代数】5-2:置换和余因子(Permutations and Cofactors)

    title: [线性代数]5-2:置换和余因子(Permutations and Cofactors) categories: Mathematic Linear Algebra keywords: ...

  3. 线性代数导论 | Linear Algebra 课程

    搞统计的线性代数和概率论必须精通,最好要能锻炼出直觉,再学机器学习才会事半功倍. 线性代数只推荐Prof. Gilbert Strang的MIT课程,有视频,有教材,有习题,有考试,一套学下来基本就入 ...

  4. Permutations II

    Given a collection of numbers that might contain duplicates, return all possible unique permutations ...

  5. [LeetCode] Permutations II 全排列之二

    Given a collection of numbers that might contain duplicates, return all possible unique permutations ...

  6. [LeetCode] Permutations 全排列

    Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the follow ...

  7. POJ2369 Permutations(置换的周期)

    链接:http://poj.org/problem?id=2369 Permutations Time Limit: 1000MS   Memory Limit: 65536K Total Submi ...

  8. Permutations

    Permutations Given a collection of distinct numbers, return all possible permutations. For example,[ ...

  9. 【leetcode】Permutations

    题目描述: Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the ...

随机推荐

  1. 计时器 vb

    十分钟 我们寒假就是这么长!! vb 执行cmd   :              shell "cmd /c DOS命令" vb 取系统日期: Print Date; " ...

  2. CV_Assert

    转:http://blog.csdn.net/ding977921830/article/details/46376847 Checks a condition at runtime and thro ...

  3. npm安装appium server路过的坑

    1.因为appium服务器是用node.js开发的,所以第一步要安装nodejs. 安装后,系统默认配置的环境变量在C盘的用户目录下,为了避免以后下载的包都放在系统盘下, 配置npm下载的包存放目录和 ...

  4. 20个Flutter实例视频教程-第14节: 展开闭合列表案例

    博客地址; https://jspang.com/post/flutterDemo.html#toc-5b0 视频地址: https://www.bilibili.com/video/av397092 ...

  5. 原生JS操作 table object HTMLTableSectionElement 对象,获取行数

    <tbody id="infoTab"> <tr class="fomat"> <td class="blank&quo ...

  6. MySQL(12)---纪录一次left join一对多关系而引起的BUG

    MySQL(11)---纪录一次left join一对多关系而引起的bug BUG背景 我们有一个订单表 和 一个 物流表 它们通过 订单ID 进行一对一的关系绑定.但是由于物流表在保存订单信息的时候 ...

  7. Maven虐我千百遍,我待Maven如初恋

    前言 在如今的互联网项目开发当中,特别是Java领域,可以说Maven随处可见.Maven的仓库管理.依赖管理.继承和聚合等特性为项目的构建提供了一整套完善的解决方案,可以说如果你搞不懂Maven,那 ...

  8. 微信小程序中时间戳和日期的相互转换

    在微信开发小程序时,后台传入的诗句可能是 时间戳 而不是日期  或者需要把日期转换成时间戳来做出相应的处理时我们将用到时间戳和日期的相互转换微信小程序里, 时间戳转化为日期格式,支持自定义.拷贝至项目 ...

  9. [Xcode 实际操作]一、博主领进门-(4)设置项目的属性

    目录:[Swift]Xcode实际操作 本文将演示如何设置项目的属性. 点击项目名称[DemoApp],打开项目信息面板. [Identity识别]设置区域 [Display Name]:DemoAp ...

  10. python 之 函数 装饰器

    5.8 装饰器 1 开放封闭原则 软件一旦上线后,就应该遵循开放封闭原则,即对修改源代码是封闭的,对功能的扩展是开放的 也就是说我们必须找到一种解决方案: 能够在不修改一个功能源代码以及调用方式的前提 ...