A15696 | Graph Coloring (easy version)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The only difference between the easy and the hard version is the constraint on $n$ .
You are given an undirected complete graph on $n$ vertices. A complete graph is a graph where each pair of vertices is connected by an edge. You have to paint the edges of the graph into two colors, red and blue (each edge will have one color).
A set of vertices $S$ is red-connected if, for every pair of vertices $(v_1, v_2)$ such that $v_1 \in S$ and $v_2 \in S$ , there exists a path from $v_1$ to $v_2$ that goes only through red edges and vertices from $S$ . Similarly, a set of vertices $S$ is blue-connected if, for every pair of vertices $(v_1, v_2)$ such that $v_1 \in S$ and $v_2 \in S$ , there exists a path from $v_1$ to $v_2$ that goes only through blue edges and vertices from $S$ .
You have to paint the graph in such a way that:
- there is at least one red edge;
- there is at least one blue edge;
- for each set of vertices $S$ such that $|S| \ge 2$ , $S$ is either red-connected or blue-connected, but not both.
Calculate the number of ways to paint the graph, and print it modulo $998244353$ .
You are given an undirected complete graph on $n$ vertices. A complete graph is a graph where each pair of vertices is connected by an edge. You have to paint the edges of the graph into two colors, red and blue (each edge will have one color).
A set of vertices $S$ is red-connected if, for every pair of vertices $(v_1, v_2)$ such that $v_1 \in S$ and $v_2 \in S$ , there exists a path from $v_1$ to $v_2$ that goes only through red edges and vertices from $S$ . Similarly, a set of vertices $S$ is blue-connected if, for every pair of vertices $(v_1, v_2)$ such that $v_1 \in S$ and $v_2 \in S$ , there exists a path from $v_1$ to $v_2$ that goes only through blue edges and vertices from $S$ .
You have to paint the graph in such a way that:
- there is at least one red edge;
- there is at least one blue edge;
- for each set of vertices $S$ such that $|S| \ge 2$ , $S$ is either red-connected or blue-connected, but not both.
Calculate the number of ways to paint the graph, and print it modulo $998244353$ .
输入格式
The first (and only) line contains one integer $n$ ( $3 \le n \le 5 \cdot 10^3$ ).
输出格式
Print one integer — the number of ways to paint the graph, taken modulo $998244353$ .
输入输出样例
输入 #1
3
输出 #1
6
输入 #2
4
输出 #2
50
输入 #3
100
输出 #3
878752271
输入 #4
1337
输出 #4
520628749
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted