exec_outcome
stringclasses
1 value
code_uid
stringlengths
32
32
file_name
stringclasses
111 values
prob_desc_created_at
stringlengths
10
10
prob_desc_description
stringlengths
63
3.8k
prob_desc_memory_limit
stringclasses
18 values
source_code
stringlengths
117
65.5k
lang_cluster
stringclasses
1 value
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_time_limit
stringclasses
27 values
prob_desc_sample_outputs
stringlengths
2
796
prob_desc_notes
stringlengths
4
3k
lang
stringclasses
5 values
prob_desc_input_from
stringclasses
3 values
tags
listlengths
0
11
src_uid
stringlengths
32
32
prob_desc_input_spec
stringlengths
28
2.37k
difficulty
int64
-1
3.5k
prob_desc_output_spec
stringlengths
17
1.47k
prob_desc_output_to
stringclasses
3 values
hidden_unit_tests
stringclasses
1 value
PASSED
7efd76ef0420bd1ad3fff4d7fb25bb17
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class Main { static BufferedReader bf; static PrintWriter out; static Scanner sc; static StringTokenizer st; // static long mod = (long)(1e9+7); static long mod = 998244353; static long fact[]; static long inverse[]; public static void main (Strin...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
2d4ed22ff2016f30199bdfe82d67ba38
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
// OM NAMAH SHIVAY // 27 days remaining(2609) import java.math.BigInteger; import java.util.*; import java.io.*; public class Vaibhav { static boolean prime[]; static class Pair implements Comparable<Pair> {int a;int b;Pair(int a, int b) {this.a = a;this.b = b;}public boolean equals(Object ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
e332f50d1d4ebcc82404ae6871f8a478
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class CodeForces { /*-------------------------------------------EDITING CODE STARTS HERE-------------------------------------------*/ public static void solve(int tCase) throws IOException { int n = sc.nextInt(); int k = sc.nextInt(); parent...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
1e8d7327c38c9e3a9250c45c691a6be4
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.io.*; public class D { static class Pair { int f; int s; // Pair() { } Pair(int f, int s) { this.f = f; this.s = s; } } static class Fast { BufferedReader br; ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
f61e3edd470055ad65cabc567da4a9b9
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.io.*; public class D { static class Pair { int f; int s; // Pair() { } Pair(int f, int s) { this.f = f; this.s = s; } } static class Fast { BufferedReader br; ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
c0f8a228a64cb500f36783367a4c80ca
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.io.*; public class Main { static Scanner sc; static PrintWriter pw; static int depth[][], par[]; static boolean[] vis; static void dfs(int u) { vis[u] = true; if (u == 0) return; if (vis[par[u]]) { depth[u][0] = 1 + depth[par[u]][0]; depth[u][1] = u; ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
53590caae8e3e228a1c01aa5852cee37
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class ResetKEdges { private static final int START_TEST_CASE = 1; public static void solveCase(FastIO io, int testCase) { final int N = io.nextInt(); final int K = io.nextInt(); Node[] nodes = new Node[N + 1]; for (int i = 1; i <= N; ++i) { nod...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
13c7da90cdf725651b647ff1020b6233
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class ResetKEdges { private static final int START_TEST_CASE = 1; public static void solveCase(FastIO io, int testCase) { final int N = io.nextInt(); final int K = io.nextInt(); Node[] nodes = new Node[N + 1]; for (int i = 1; i <= N; ++i) { nod...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
4b3d59a5d9b776ab20e74829ec9f949b
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class ResetKEdges { private static final int START_TEST_CASE = 1; public static void solveCase(FastIO io, int testCase) { final int N = io.nextInt(); final int K = io.nextInt(); Node[] nodes = new Node[N + 1]; for (int i = 1; i <= N; ++i) { nod...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
0fbaafdfa915ffc907385ab31d72157c
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class Main { static Main2 admin = new Main2(); public static void main(String[] args) { admin.start(); } } class Main2 { //---------------------------------INPUT READER-----------------------------------------// public BufferedRead...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
8eb37e9e1c3ae26c5168d0b6a1fad63c
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
/* Goal: Become better in CP! Key: Consistency and Discipline Desire: SDE @ Google USA Motto: Do what i Love <=> Love what i do If you don't use your brain 100%, it deteriorates gradually */ import java.util.*; import java.io.*; import java.math.*; public class B1 { static StringBuffer str=...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
1e7c013e3af69ff444a40124f4f9bea1
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; /** * Author : joney_000[developer.jaswant@gmail.com] * Algorithm : Default Template * Platform : Codeforces * Ref : N/A */ public class A{ private InputStream inputStream ; private OutputStream outputStream ; priva...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
5c3549fd312dc378dd0e6c971562347e
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class Main { private static void solve(int n, int k, Map<Integer, List<Integer>> g){ int start = 1, end = n - 1; while(start + 1 < end){ int mid = start + (end - start) / 2; if(isValid(mid, k, g)){ ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
8bced60e1d294094eeafec9085ec380b
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
// package faltu; import java.util.*; import java.util.Map.Entry; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Print...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
2b611652c0d7ff692542dec02fe68c6b
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
3ba1b53d58d8a4e42aa2def6a3cddbcc
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.io.*; // res.append("Case #"+(p+1)+": "+hh+" \n"); ////*************************************************************************** /* public class E_Gardener_and_Tree implements Runnable{ public static void main(String[] args) throws Exception { new Thr...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
cd977778b77572bbd30b1560c20fdfb4
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.lang.*; import java.math.BigInteger; import java.util.*; public class Solution { public static void main(String[] args) throws Exception { FastScanner fs = new FastScanner(); int t = fs.nextInt(); while (t-- != 0) { int n = fs.nextInt(), k = fs.nextInt(); List<Intege...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
5d647a7f757c4ec727a78c4880acc8b2
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class ResetKEdges_1739D { static List<Integer>[] children; static int[] parent; static int count; @SuppressWarnings("unchecked") public static void main(String[] args) throws NumberFormatException, IOException { // TODO Auto-generated method stub Buffe...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
22f12f2cf8e44ab184b8056d234ef91b
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; public class assignment { static int cuts = 0; private static int dfs(ArrayList<ArrayList<Integer>> graph, int root, int heightReq, int parent){ int height = 0; for(int i:graph.get(root)){ height=Math.max(height, dfs(graph,i, heightReq, root)); } if(height+1==heightReq && par...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
a9523efd8fed7cfee78a5fcc26ed23aa
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.BufferedReader; import java.io.Closeable; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.time.Clock; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; imp...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
cd4852643f76c64e96a716bd60bca6c9
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class Solution { private static boolean useInFile = false; private static boolean useOutFile = false; public static void main(String args[]) throws IOException { InOut inout = new InOut(); Resolver resolver = new Resolver(inout); ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
55a58152233a4807e9c50b7082249daf
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.io.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == n...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
7f49d3985ddd64ddf8f0516f7bda69d6
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class Solution { static Scanner sc = new Scanner(System.in); static StringBuilder out = new StringBuilder(); static String testCase = "Case #"; static long mod = 998244353; public static void main(String[] args) throws IOException { // TODO Auto-gene...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
088273522592989fdf679fae561e933b
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; public class CF1{ public static void main(String[] args) { FastScanner sc=new FastScanner(); // hamare saath shree raghunath to kis baat ki chinta......
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 8
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
85dc31d8ad31d089703b6f684e5343fa
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
//Utilities import java.io.*; import java.util.*; public class a { static int t; static int n, k; static HashSet<Integer>[] adj; static int[] p, deg; static int res; public static void main(String[] args) throws IOException { t = in.iscan(); outer : while (t-- > 0) { n = in.iscan(); k = in...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
5af8066b10dd2c498b4230f738c6ac89
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) { new MainClass().execute(); } } class MainClass extends PrintWriter { MainClass() { super(System.out, true); } boolean cases = true; // Solution List<Integer>[] al; int...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
eb9a34609ae64f406119392e11aef8d8
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) { new MainClass().execute(); } } class MainClass extends PrintWriter { MainClass() { super(System.out, true); } boolean cases = true; // Solution List<Integer>[] al; int...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
217e5e922cfdf518bd952ebdfb76e77e
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import static java.lang.Math.*; public class D { public Object solve () { int N = sc.nextInt(), K = sc.nextInt(); int [] P = dec(sc.nextInts()); int [][] E = new int [N-1][]; for (int i : rep(N-1)) E[i] = new int [] { P[i], i+1 }; G = dgraph(N, E); H = new boolean [N]; H[0] = true; f...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
06585f0fa8e5b5c364f6b70d177e87b5
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import static java.lang.Math.*; public class D { public Object solve () { int N = sc.nextInt(), K = sc.nextInt(); int [] P = dec(sc.nextInts()); int [][] E = new int [N-1][]; for (int i : rep(N-1)) E[i] = new int [] { P[i], i+1 }; G = dgraph(N, E); H = new boolean [N]; H[0] = true; f...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
7f9be1ce9084d6547a9f23825df5e12a
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.InputMismatchException; import java.util.function.Predicate; public class E1739D { static int n; static ArrayList<Integer>[] adj; static int k; static int allowedK; static int[] dep; public static void main(Stri...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
d16ceee62d9b709a865ce85953618e2c
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next() throws IOException { if (!tok.h...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
cb81110f2f6c7d716403abcd02bd0ccd
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; public class ComdeFormces { static int x[]= {-1,0,0,1,1,1,-1,-1}; static int y[]= {0,1,-1,0,1,-1,1,-1}; static int dp[][][][]; static int seg[]; static class Trie{ Trie a[]; int ind; public Trie() { this.a=new Trie[3]; this.ind...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
bd4f4fd802980400426884206d2fa282
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; public class Main { static int t; static Vector<Vector<Integer>> a = new Vector<Vector<Integer>>(); static Scanner scanner = new Scanner(System.in); static Pair dfs(int u, int p, int m){ Pair res = new Pair(1, 0); for(int v: a.get(u)){ Pair val...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
880fae05e10acc047e0d6969f0d4f33b
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class D { static IOHandler sc = new IOHandler(); static List<Integer> [] graph; static int [] depth; public static void main(String[] args) { // TODO Auto-generated method stub int testCases = sc.nextInt(); for (int i = 1; i <= testCases; ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
1e07629d950e4a337afdea881412cc78
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class D { public static void main(String[] args) throws IOException{ BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
25b59cc9b0ab21665eca98bfeb09cd42
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class q4 { static int count; public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.ne...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
a4d927608c168ee8ce722b17a4e5790a
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; public class D { public static final int MOD998 = 998244353; public static final int MOD100 = 1000000007; static int count = 0; static int[][] graph; public static void main(String[] args) throws Exception { ContestScanner sc = new ContestScanner(); ContestPrin...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
c42b0988e2fc7a810335124e8231a379
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
// package c1739; // // Educational Codeforces Round 136 (Rated for Div. 2) 2022-09-29 07:35 // D. Reset K Edges // https://codeforces.com/contest/1739/problem/D // time limit per test 4 seconds; memory limit per test 256 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*class...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
eb25bd3fdf1f0672d02006335d9a4dc6
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
// package c1739; // // Educational Codeforces Round 136 (Rated for Div. 2) 2022-09-29 07:35 // D. Reset K Edges // https://codeforces.com/contest/1739/problem/D // time limit per test 4 seconds; memory limit per test 256 megabytes // public class Pseudo for 'Source should satisfy regex [^{}]*public\s+(final)?\s*class...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
ab2b27f30616dade9ae54526f5c77ffb
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class d { static int maxN = 200005; public static int[] p = new int[maxN]; static ArrayList<Integer>[] c = new ArrayList[maxN]; static TreeMap<Integer, Integer>[] cdepth = new TreeMap[maxN]; static int n; public static void main(String[] a...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
a5a92e1cdfc4bbd2dc045a9b28f668da
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.math.BigInteger; import java.util.*; import java.io.*; public class Shivaya { static boolean prime[]; static class Pair implements Comparable<Pair> {int a;int b;Pair(int a, int b) {this.a = a;this.b = b;}public boolean equals(Object o) {if (o instanceof Pair) {Pair p = (Pair) o;retu...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
45292b03d7edfadc4ae4160262952c97
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); int t=Integer.parseInt(bu.readLine()); ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
91d5c81e1bb38948e61a04db393be8b9
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; public class Main { public static int count=0; public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); for(int w=1;w<=t;w++) { int n = scn.nextInt(); int k = scn...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
ed756fdc733ee826f8ef26ff3197d188
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class ResetKEdges { static ArrayList<ArrayList<Integer>> al = new ArrayList<>(); static int n = 0; static int k = 0; static int count = 0; public static void mai...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
77215bb65ca58aec9997056e2200d398
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { long mod1 = (long) 1e9 + 7; int mod2 = 998244353; ArrayList<ArrayList<Integer>> list; int n, k; int need=0; int mid=0; int height[]; ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
ccf0a361747cf9ca7a3ba78a082d8431
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
/* "Everything in the universe is balanced. Every disappointment you face in life will be balanced by something good for you! Keep going, never give up." Just have Patience + 1... */ import java.util.*; import java.lang...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
7d9657374aa01786f3db9d41f7ccbb17
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.HashSet; import java.util.StringTokenizer; public class D { private final static String inputFileName = null; private final static String outputFileName = null; public static void main(String[] args) { try (Solver solver = new Solver(inputFileName, outpu...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
bb55e3196f6bf60ed7df6442287841ad
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class Main { static Scanner sc; static PrintWriter out; public static void main(String[] args) { sc = new Scanner(System.in); out = new PrintWriter(System.out); int t = 1; if (true) { t = sc.nextInt(); ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
f6ae7f5b912749a73a79e29be7ca9cd6
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.io.*; public class Main { private static final void solve() throws IOException { final int n = ni(), k = ni(), m = n - 1; var p = new int[m]; for (int i = 0; i < m; i++) p[i] = ni() - 1; var ty_cnt = new int[n]; for (int i = 0; i <...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 11
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
3a7c8686625a00a507501bd03afe3a4a
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.util.function.*; import java.io.*; // you can compare with output.txt and expected out public class RoundEdu136D { MyPrintWriter out; MyScanner in; // final static long FIXED_RANDOM; // static { // FIXED_RANDOM = System.currentTimeMillis(); // } final static String I...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 17
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
b086051e25c8dea609904cd114c8cc4f
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.io.*; public class User { static int ans; public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String [] line = br.readLine().split(" "); int t = Integer.parseInt(li...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 17
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
cb03403d58a5c41640fadaff9d49cb39
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.util.*; import java.io.*; public class User { static int ans; public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String [] line = br.readLine().split(" "); int t = Integer.parseInt(li...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 17
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
d71f6abcf4a0e21ccef39d27bbbb059f
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here Buf...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 17
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
fc973bd622978fa40dcb5a92b3aa4fca
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import static java.lang.Math.max; public class Main { static FastReader fastReader = new FastReader(); public static void main(String[] args) { int t = fastReader.nextInt(); ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 17
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
2a007364fd060a533cbb4f1bbe4d2bdb
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import j...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 17
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
313fdd8f637ebcf46bfdc2e335117626
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import static java.lang.Math.*; public class D { public Object solve () { int N = sc.nextInt(), K = sc.nextInt(); int [] P = dec(sc.nextInts()); int [][] E = new int [N-1][]; for (int i : rep(N-1)) E[i] = new int [] { P[i], i+1 }; G = dgraph(N, E); H = new boolean [N]; H[0] = true; f...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 17
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
c317a880f287905bd2aecb04462f01bd
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.sql.Array; import java.util.*; import java.io.*; import java.math.BigInteger; import java.util.stream.IntStream; import java.util.stream.LongStream; public class Main { public static FastReader cin; public static PrintWriter out; public static long MOD = 998244353L; public ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 17
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
c58974303fd9eb20c193a2042addec7c
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here Buf...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 17
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
14932c5b927d41eeff07fcb7b7a29915
train_109.jsonl
1664462100
You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times: choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$; remove the edge $$$(v, u)$$$;...
256 megabytes
import java.io.*; import java.util.*; public class CF1739D extends PrintWriter { CF1739D() { super(System.out); } static class Scanner { Scanner(InputStream in) { this.in = in; } InputStream in; byte[] bb = new byte[1 << 15]; int i, n; byte getc() { if (i == n) { i = n = 0; try { n = in.read(bb); } ...
Java
["5\n\n5 1\n\n1 1 2 2\n\n5 2\n\n1 1 2 2\n\n6 0\n\n1 2 3 4 5\n\n6 1\n\n1 2 3 4 5\n\n4 3\n\n1 1 1"]
4 seconds
["2\n1\n5\n3\n1"]
null
Java 17
standard input
[ "binary search", "data structures", "dfs and similar", "graphs", "greedy", "trees" ]
f260d0885319a146904b43f89e253f0c
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perfo...
1,900
For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.
standard output
PASSED
e4fe1acd2230a6ed154739b1d54fc3cf
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
/* Goal: Become better in CP! Key: Consistency and Discipline Desire: SDE @ Google USA Motto: Do what i Love <=> Love what i do If you don't use your brain 100%, it deteriorates gradually */ import java.util.*; import java.io.*; import java.math.*; public class Solution { static StringBuffe...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
cf039486867e67a51b948e84791842a2
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
/* Goal: Become better in CP! Key: Consistency and Discipline Desire: SDE @ Google USA Motto: Do what i Love <=> Love what i do If you don't use your brain 100%, it deteriorates gradually */ import java.util.*; import java.io.*; import java.math.*; public class Solution { static StringBuffe...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
39646f6c96cd7f10a2a113727227d6ad
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.util.*; public class C_Card_Game { static int MOD = 998244353; public static int solve(int n){ if(n <= 0) return 0; // total games nCn/2 // number of games Alex wins -> if he receives number n then alex wins int a1 = modncr(n-1,(n/2)-1)...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
794d2bead795d2a2308810fc41c8d4b8
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.PriorityQueue; import java.util.StringTokenizer; import java....
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
ba37f1fa78cec8ea6bcf7d72ae23f000
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigDecimal; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
69ab6525fa43bb939c4084edfb8c04d7
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import jav...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
837eea40e5a7e3287bbf6129d053f074
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import jav...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
23e8c4e56315af8d806525aaf89e9bca
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; public class Main { static InputReader in; static OutputWriter out; static long[][] c=new long[65][65]; static long mod=998244353; public static void main(String[] args) throws Exception { in=new InputReader(System.in); out=new OutputWriter(System....
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
be65e503cd160167d1de74337353ad8e
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
/*############################################################################################################ ########################################## >>>> Diaa12360 <<<< ############################################### ########################################### Just Nothing ###################################...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
4e9b421b5b4ea7e315efd2b7952802a8
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
/*############################################################################################################ ########################################## >>>> Diaa12360 <<<< ############################################### ########################################### Just Nothing ###################################...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
8ce1c08f2c16e2121e9467f4c76f1912
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.util.*; import java.io.*; public class Main { static FastReader sc=new FastReader(); static PrintWriter out=new PrintWriter(System.out); static int dx[]={0,0,-1,1,-1,-1,1,1},dy[]={-1,1,0,0,-1,1,-1,1}; static final double pi=3.1415926536; // static long mod=1000000007; static long mod=9982...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
73317488a0c8d7ce1162967c18dc97d1
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
// OM NAMAH SHIVAY // 32 days remaining(2609) import java.math.BigInteger; import java.util.*; import java.io.*; public class Vaibhav { static long bit[]; static boolean prime[]; static class Pair { int a; int b; Pair(int a, int b ) { this.a = a; ...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
442851151579bb6ef38b1b588e912979
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
//package kg.my_algorithms.Codeforces; import java.util.*; import java.io.*; // NO PROFILE CHECK public class Solution { private static final FastReader fr = new FastReader(); private static final long mod = 998244353L; public static void main(String[] args) throws IOException...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
1f78db470456bc45e88a3f175c6bb643
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { static long T[][] = {{1, 0, 1}, {3, 2, 1}, {12, 7, 1}, {42, 27, 1}, {153, 98, 1}, {560, 363, 1}, {2079, 1352, 1}, {7787, 5082, 1}, {29392, 19227, 1}, {111605, 73150, 1}, {425866, 279565, 1}, {1631643, 1072512, 1}, {6272812, 41...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
f6ac0aa309fcdc3af307135873d7d39c
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.awt.Point; import java.util.Scanner; public class C1739 { static long mod = 998244353; static long[][] choose = new long[61][61]; public static void main(String[] args) { for (int n=0; n<=60; n++) { choose[n][0] = 1; choose[n][n] = 1; for ...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
08d7ec66d729549659fa545d3ff44408
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main{ private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static final int MOD = 998244353; static long[][] dp = new long[65][2]; static long...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
3c51bbd3c650cf6455df4540caa64391
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.util.*; public class p4 { BufferedReader br; StringTokenizer st; BufferedWriter bw; public static void main(String[] args)throws Exception { new p4().run(); } void run()throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); bw=new Bu...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
a752e989892c028858553897b9e92949
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; public class CardGame { static long[][] dp; static int mod=998244353; public static void main(String[] args) throws IOException { Buffe...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
cc62b0b0fa86b0ebc3e05b1ce2167aa7
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.awt.Point; import java.util.Scanner; public class C1739 { static long mod = 998244353; static long[][] choose = new long[61][61]; public static void main(String[] args) { for (int n=0; n<=60; n++) { choose[n][0] = 1; choose[n][n] = 1; for ...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
e2eebc282921a2e7254ea8afa8295041
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.util.Scanner; public class MyClass { static Scanner in = new Scanner(System.in); static int testCases; static long a, b, c, mod = 998244353L; static void solve() { long x = 1L, y = 0L, mid = 2L; for(int i = 4; i <= (int)a; i += 2) { mid =...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
9ecaed0f32fc4684aa334f08e4f4ccb1
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.util.*; public class Main { private static final int mod = 998244353; private static long[][] C; private static void solve(int n){ if(n == 2){ out.println("1 0 1"); return; } if(n == 4){ out.println("3 2...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
f9994aa906edabad53742b7fe2128166
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.*; public class C { public static void main(String[] args){ FastReader fs=new FastReader(); PrintWriter out=new P...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
7943360948968b6aa6aca9f0ac3e7285
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; import java.util.TreeMap; public class C {...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
4b148be0e921242b8f1731edb7c2d6ef
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.math.BigInteger; import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int ii = 0; ii < t; ii++) { int n = in.nextInt(); if(n == 2) { ...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
8c8093e681fb871c442c38e7f8e230ae
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.util.*; public class assignment { static int mod = 998244353; private static long nCr(int n, int r){ if(r>n-r) r=n-r; long res=1; for(int i=0;i<r;i++){ res*=n-i; res/=i+1; } return res; } public static void main(String args[]) { Scanner s=new Scanner(System.in); ...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
ee8b167ea8d905339ab2b6b7543c19aa
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static long m = 998244353; static long n[][]; public static void main(String[] args) { FastScanner input = new FastScanner(); n = new lo...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
5376c37066f65a57fc933e0c56e34a12
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.*; public class CodeForces { /*-------------------------------------------EDITING CODE STARTS HERE-------------------------------------------*/ public static void solve(int ...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
f31df04ca8de8718a55c0a258fd482a2
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.ArrayList; import java.u...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
de032f0efd17fe873036d117350dbeea
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.util.*; import java.math.*; public class A { public static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } public static String concat(String s1, String s2) { return new StringBuilder(s1).append(s2).toString(); } static long lcm(long a, long b) { ...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
df30afafa4352364c77d125cba68d831
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
/* Author:-crazy_coder- */ import java.io.*; import java.util.*; public class cp{ static long mod=998244353; static int ans=0; static int[] par=new int[100005]; static int[] rank=new int[100005]; static BufferedReader br=new BufferedReade...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
138d45ecad14d68a034ef1ba625987e9
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.util.*; import java.math.*; public class cp { static PrintWriter w = new PrintWriter(System.out); static FastScanner s = new FastScanner(); static int mod = 1000000007; static class Edge { int src; int wt; int nbr; Edge(i...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
bd5e96f21471a95d7e58d3e276b46aee
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class C_Card_Game { static Scanner in = new Scanner(); static PrintWriter out = new PrintWriter(System.out); static StringBuilde...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
b70b997c9998a226f85a03cfe500836d
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.util.*; public class C { static class Pair { int f;int s; // Pair(){} Pair(int f,int s){ this.f=f;this.s=s;} } static class sortbyfirst implements Comparator<Pair> { public int compare(Pair a,Pair b) { r...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
fb055b0f304846ac78eba29afb24a7a5
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.util.StringTokenizer; /** * @author freya * @date 2022/9/6 **/ public class C { public static Reader in; public static PrintWriter out; public static void main(String[] args) { out = new PrintWriter(new BufferedOutputStream(System.out)); in = new...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
b184a90d2d5a1bd64582146906e3bd1e
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.util.*; import java.io.*; // res.append("Case #"+(p+1)+": "+hh+" \n"); ////*************************************************************************** /* public class E_Gardener_and_Tree implements Runnable{ public static void main(String[] args) throws Exception { new Thr...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
e54d4a79dc7d565b6968a2bce164f4a8
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
//package codeforces.edu136; import java.io.*; import java.util.*; import static java.lang.Math.*; public class C { static InputReader in; static PrintWriter out; public static void main(String[] args) { //initReaderPrinter(true); initReaderPrinter(false); solve(in....
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
b7b35486358958c2664068ba3f56793a
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.math.BigInteger; import java.util.Arrays; import java.util.StringTokenizer; import java.util.function.DoubleToIntFunction; public class Round22 { static BigInteger mod=new BigInteger(998244353+""); public static void main(String[] args) throws IOException { ...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
4e13f2ebb30155c8c80bc5dd788fa0cf
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.math.BigInteger; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.util.*; public class app { public static long m; static int mod = 998244353; static int inf = (int) 1e9; public static void main(String[] args) throws...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
cce740a0a97c65ed9b338e1d7e40d84b
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.util.*; import java.io.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == n...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
15dc81ffea69daedb47bf8d3d35690f3
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.util.*; public class Main { static BufferedReader bf; static PrintWriter out; static Scanner sc; static StringTokenizer st; // static long mod = (long)(1e9+7); static long mod = 998244353; static long fact[]; static long inverse[]; public static void main (Strin...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output
PASSED
b0b041565930ed648ca8b24ca68bb443
train_109.jsonl
1664462100
Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x &gt; y$$$.Two players, Alex and Boris, play this game. In the beginn...
512 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Codeforces { public static PrintWriter out; public static Scanner sc; public static void main(String[] args) throws IOException { sc = new Scanner(System.in); out = new PrintWriter(System.out); ...
Java
["5\n\n2\n\n4\n\n6\n\n8\n\n60"]
2 seconds
["1 0 1\n3 2 1\n12 7 1\n42 27 1\n341102826 248150916 1"]
NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case: Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$; Boris wins if Alex receives the cards $$$[1...
Java 8
standard input
[ "combinatorics", "constructive algorithms", "dp", "games" ]
63fc2fb08d248f8ccdb3f5364c96dac1
The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).
1,500
For each test case, print three integers: the number of ways to distribute the cards so that Alex wins; the number of ways to distribute the cards so that Boris wins; the number of ways to distribute the cards so that the game ends in a draw. Since the answers can be large, print them modulo $$$998244353$$$.
standard output