Biconnected Graph

AtCoder
IDagc067_e
Time3000ms
Memory256MB
Difficulty
You are given an integer $N$ and a prime $P$. Count the number, modulo $P$, of undirected connected graphs $G$ of $N$ vertices numbered $1$ to $N$ that satisfy the following condition: * There are no self-loops in $G$. Note that multiple edges are allowed. * For all edges $(u,v)$ in $G$, if we delete $(u,v)$ from $G$, $G$ remains connected. In other words, $G$ is edge-biconnected. * For all edges $(u,v)$ in $G$, if we delete $(u,v)$ from $G$, $G$ is no longer edge-biconnected. Two graphs are considered different if and only if there exists a pair of distinct vertices $(u,v)$ such that the numbers of edges connecting $u$ and $v$ in the two graphs are different. ## Constraints * $2 \le N \le 50$ * $10^9<P<1.01\times 10^9$ * $P$ is prime. * All input values are integers. ## Input Input is given from Standard Input in the following format: $N$ $P$ [samples]
Samples
Input #1
2 1005976817
Output #1
1
Input #2
5 1000837403
Output #2
372
Input #3
10 1001160547
Output #3
789846604
Input #4
20 1006779551
Output #4
888612770
API Response (JSON)
{
  "problem": {
    "name": "Biconnected Graph",
    "description": {
      "content": "You are given an integer $N$ and a prime $P$. Count the number, modulo $P$, of undirected connected graphs $G$ of $N$ vertices numbered $1$ to $N$ that satisfy the following condition: *   There are ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc067_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given an integer $N$ and a prime $P$.\nCount the number, modulo $P$, of undirected connected graphs $G$ of $N$ vertices numbered $1$ to $N$ that satisfy the following condition:\n\n*   There are ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments