CF1792F1.Graph Coloring (easy version)
省选/NOI-
通过率:0%
时间限制:5.50s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 (v1,v2) such that v1∈S and v2∈S, there exists a path from v1 to v2 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 (v1,v2) such that v1∈S and v2∈S, there exists a path from v1 to v2 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∣≥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.
简单版本与困难版本的唯一区别在于 n 的约束条件。
给你一个包含 n 个顶点的无向完全图。完全图是指图中每一对顶点之间都有一条边相连。你需要将图中的所有边染成两种颜色之一:红色或蓝色(每条边恰好染一种颜色)。
若对顶点集合 S,任意两个顶点 v1,v2∈S 均存在一条仅由红色边及 S 中的顶点构成的路径,则称 S 是红连通的。类似地,若对任意 v1,v2∈S,均存在一条仅由蓝色边及 S 中的顶点构成的路径,则称 S 是蓝连通的。
你需要对图进行染色,使得满足以下条件:
- 至少存在一条红色边;
- 至少存在一条蓝色边;
- 对每个满足 ∣S∣≥2 的顶点集合 S,S 要么是红连通的,要么是蓝连通的,但不能两者同时成立。
计算满足上述条件的染色方案数,并将结果对 998244353 取模后输出。
输入格式
The first (and only) line contains one integer n (3≤n≤5⋅103).
第一行(也是唯一一行)包含一个整数 n(3≤n≤5⋅103)。
输出格式
Print one integer — the number of ways to paint the graph, taken modulo 998244353.
输出一个整数——染色该图的方案数,对 998244353 取模。
输入输出样例
输入#1
3
输出#1
6
输入#2
4
输出#2
50
输入#3
100
输出#3
878752271
输入#4
1337
输出#4
520628749
输入解题思路,AI测评打分。不知道怎么写?