Codeforces Round #382 (Div. 1), problem: (D) Permutations Solution in C/C++

By | 2017-04-07T22:11:48+00:00 December 17th, 2016|Categories: C/C++, Programming|Tags: , , , , , , , |

#include <bits/stdc++.h> using namespace std; const int N=2e3+1; int n,m,x[N*N],y[N*N]; bitset<N*2> a[N]; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) { scanf("%d%d",x+i,y+i); x[i]--; y[i]--; a[x[i]].set(y[i]); } for(int i=0;i<n;i++) a[i][i+n]=1; for(int i=0;i<n;i++) { for(int j=i;j<n;j++) { if(a[j][i]) { swap(a[j],a[i]); break; } } for(int j=0;j<n;j++) { if(j!=i&&a[j][i]) a[j]^=a[i]; [...]