Alice and Bob are playing a game on a graph. They have an undirected graph without self-loops and multiple edges. All vertices of the graph have degree equal to 22. The graph may consist of several components. Note that if such graph has n� vertices, it will have exactly n� edges.
Alice and Bob take turn. Alice goes first. In each turn, the player can choose k� (l≤k≤r�≤�≤�; l<r�<�) vertices that form a connected subgraph and erase these vertices from the graph, including all incident edges.
The player who can't make a step loses.
For example, suppose they are playing on the given graph with given l=2�=2 and r=3�=3:
A valid vertex set for Alice to choose at the first move is one of the following:
- {1,2}{1,2}
- {1,3}{1,3}
- {2,3}{2,3}
- {4,5}{4,5}
- {4,6}{4,6}
- {5,6}{5,6}
- {1,2,3}{1,2,3}
- {4,5,6}{4,5,6}
Suppose, Alice chooses subgraph {4,6}{4,6}.
Then a valid vertex set for Bob to choose at the first move is one of the following:
- {1,2}{1,2}
- {1,3}{1,3}
- {2,3}{2,3}
- {1,2,3}{1,2,3}
Suppose, Bob chooses subgraph {1,2,3}{1,2,3}.
Alice can't make a move, so she loses.
You are given a graph of size n� and integers l� and r�. Who will win if both Alice and Bob play optimally.
Input
The first line contains three integers n�, l� and r� (3≤n≤2⋅1053≤�≤2⋅105; 1≤l<r≤n1≤�<�≤�) — the number of vertices in the graph, and the constraints on the number of vertices Alice or Bob can choose in one move.
Next n� lines contains edges of the graph: one edge per line. The i�-th line contains two integers ui�� and vi�� (1≤ui,vi≤n1≤��,��≤�; ui≠vi��≠��) — description of the i�-th edge.
It's guaranteed that the degree of each vertex of the given graph is equal to 22.
Output
Print Alice (case-insensitive) if Alice wins, or Bob otherwise.
Code
#include<bits/stdc++.h> using namespace std; inline int in(){ int x; scanf("%d",&x); return x; } const int N=2e5+5; int n,l,r; int fa[N],sz[N]; int gf(int x){return x==fa[x]?x:fa[x]=gf(fa[x]);} int sg[N]; int main(){ n=in(),l=in(),r=in(); for(int i=1;i<=n;i++)fa[i]=i,sz[i]=1; for(int i=1;i<=n;i++){ int x=gf(in()),y=gf(in()); if(x!=y)fa[y]=x,sz[x]+=sz[y]; } int ans=0; for(int i=1;i<=n;i++){ if(gf(i)==i&&sz[i]<l+r){ ans^=sz[i]/l; } } puts(ans?"Alice":"Bob"); return 0; }