Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[122] ={0};
- bool U[11]={false};
- void raspr(int N, int Q, int previous) {
- if (N == Q)
- a[121]+=1;
- else
- for(int i = 0; i < N; i++) {
- if (!U[i] && ( previous==-1 || a[N*i + previous])) {
- U[i] = true;
- raspr(N, Q + 1, i);
- U[i] = false;
- }
- }
- }
- int main() {
- int N, K;
- cin >> N >> K;
- for (int i = 0 ; i< N;i++)
- for (int j = 0; j < N ;j++)
- a[i*N+j]=1;
- for(int z = 0; z < K ; z++) {
- int i , j;
- cin >> i >> j;
- a[j*N+i-1-N]=a[i*N+j-1-N]=0;
- }
- raspr(N, 0, -1);
- cout << a[121];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement