RecursiveTournament
SRM 783 · 2020-03-30 · by lg5293
Problem Statement
A tournament graph is a graph where every pair of distinct nodes has a single directed edge between them.
Consider a touranment graph with b nodes such that the nodes are labeled with the digits of the base b.
For example, if b=3, then there would be three nodes, labeled 0, 1, and 2.
You are given this tournament graph in the
You are given a
For example, if b=3 and k=4, then consider the nodes 1 and 6. 1 in base 3 with 4 digits is 0001, and 6 in base 3 with 4 digits is 0020. The leftmost digit in which they differ is the third digit from the left, so the edge between 1 and 6 in the big graph would have the same direction as the edge between 0 and 2 in the input graph.
An induced subgraph of a graph is a subset of its nodes along with all the edges between those nodes. A non-empty graph is strongly connected if it contains directed paths from every node to every other node. In particular, a graph with a single node is considered strongly connected. Given the input graph and number k, how many non-empty strongly connected induced subgraphs are there in the big tournament graph? Since this number can get very large, return it modulo 998244353.
Constraints
- b will be between 3 and 23.
- graph will have exactly b elements.
- Each element of graph will have exactly b characters, each of which is either 'Y' or 'N'.
- graph describes a valid tournament graph.
- k will be between 1 and 1000.
{
"NYN",
"NNY",
"YNN"
}
2
Returns: 355
{
"NYY",
"NNY",
"NNN"
}
2
Returns: 9
{
"NYN",
"NNY",
"YNN"
}
1
Returns: 4
{
"NYYYNNYNNYYNNYYYYYNNYNN",
"NNYNYYNYYNNNYNYNYNNNNYY",
"NNNNYNNNNYNYYNYYNYYNYNN",
"NYYNYNNNYNNYYYNYYYNNYYN",
"YNNNNNYYNYNNYYNNYNYNYYY",
"YNYYYNNNYNYNYNYNNYNYNYN",
"NYYYNYNNNYYNNNNYNNNNYNN",
"YNYYNYYNYYYNYNYYYNYNNYY",
"YNYNYNYNNYYYNYNYNYYYNYN",
"NYNYNYNNNNYNYYYNNYYYNYN",
"NYYYYNNNNNNNNYNYYNNYNYN",
"YYNNYYYYNYYNNYYYYNYYYNY",
"YNNNNNYNYNYYNNNNYNYNYNY",
"NYYNNYYYNNNNYNYNNNNYNYN",
"NNNYYNYNYNYNYNNYNNNYNNY",
"NYNNYYNNNYNNYYNNYNYYNYN",
"NNYNNYYNYYNNNYYNNNYNNNN",
"NYNNYNYYNNYYYYYYYNYYYNN",
"YYNYNYYNNNYNNYYNNNNNYNY",
"YYYYYNYYNNNNYNNNYNYNYNN",
"NYNNNYNYYYYNNYYYYNNNNNY",
"YNYNNNYNNNNYYNYNYYYYYNY",
"YNYYNYYNYYYNNYNYYYNYNNN"
}
1000
Returns: 71573222
{
"NYN",
"NNY",
"YNN"
}
1000
Returns: 93495615
Submissions are judged against all 89 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class RecursiveTournament with a public method int count(vector<string> graph, int k) · 89 test cases · 2 s / 256 MB per case