题意

$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. ADB命令小结

    )adb devices //查看启动的所有设备 )adb kill-server //重启设备 )adb start-server //启动设备 )adb -s emulator-(通过 adb d ...

  2. 深度学习之Batch归一化

    前言            以下内容是个人学习之后的感悟,转载请注明出处~ Batch归一化 在神经网络中,我们常常会遇到梯度消失的情况,比如下图中的sigmod激活函数,当离零点很远时,梯度基本为0 ...

  3. CSS3:nth-child()伪类选择器,Table表格奇偶数行定义样式

    转自爱设计 原文链接http://www.dangshopex.com/jishufenxiang/WEBkaifajishu/8653.html CSS3的强大,让人惊叹,人们在惊喜之余,又不得不为 ...

  4. POJ 3262 Protecting the Flowers 贪心(性价比)

    Protecting the Flowers Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7812   Accepted: ...

  5. POJ - 3253 Fence Repair 优先队列+贪心

    Fence Repair Farmer John wants to repair a small length of the fence around the pasture. He measures ...

  6. C#基础:通过委托给任何对象数组进行排序

    在日常编写程序的时候,我们需要对一些对象进行排序,比如对int数组进行排序,自定义类数组进行排序,首先我们先讨论对数组进行排序,我们应该对冒泡排序比较熟悉,下面是数组用冒泡排序的方法 for (int ...

  7. django使用QQ企业邮箱发送邮件

    一.首先申请QQ企业邮箱 免费QQ企业邮箱地址如下:https://exmail.qq.com/signupfree?refer=intro#signup/free 二.配置自己的域名 在域名解析中添 ...

  8. Swift3.0 数组(Array)

    学习了数组的定义,创建,和元素的,增,删,改 //定义数组类型 var array1: Array<String> var array2:[String] //创建一个空数组,int类型元 ...

  9. html实现点击图片放大功能

    话不多说,直接上代码 <html> <head> <style> .over {position: fixed; left:0; top:0; width:100% ...

  10. C#利用WebService接口下载文件

    WebTest.RtTfSimDataInterface test = new WebTest.RtTfSimDataInterface(); //string strBasic = test.Get ...