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 | b108aeff97603341f1a87ae8c07373a8 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.*;
import java.lang.*;
import java.util.*;
public class ComdeFormces {
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
FastReader sc=new FastReader();
BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 7ec09b7e31fcdbeb1e5978228e05c83b | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;
import javax.print.DocFlavor.INPUT_STREAM;
import java.io.*;
import java.math.*;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLIntegrityConstraintViolationException;
public class Main {
private static class MyScanner {
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | d12bc66d3187307fdaee10f01c71998f | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;
public class C_Factorials_and_Powers_of_Two {
static long mod = Long.MAX_VALUE;
public static void main(String[] args) {
Output... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 7147bde1b9121b8e439c090c60647eae | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | // package FirstPackage;
import java.util.*;
import java.lang.Math;
import java.io.* ;
public class Account {
public static class Pair<Object1 ,Object2> {
Object1 key ;
Object2 val ;
Pair(Object1 key ,Object2 val) {
this.key = key ;
this.val = val ;
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | a6fa0a29364b73d8d6ee5ceb64b12d47 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.Scanner;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.ArrayList;
public class factorial {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
int tt = in.nextInt();
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 90049aa480786c0b6608c41b869ccb79 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | //Utilities
import java.io.*;
import java.util.*;
public class a {
static int t;
static long n;
static final long maxn = (long)1e12;
static ArrayList<Long> arrPow, arrFac;
static HashMap<Long, Integer> facMap;
static int sz;
static long min;
public static void main(String[] args) throws IOExcepti... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | a5e8d6c756faeb1dbd957a0880fbb1fe | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | //Utilities
import java.io.*;
import java.util.*;
public class a {
static int t;
static long n;
static final long maxn = (long)1e12;
static ArrayList<Long> arrPow, arrFac;
static HashMap<Long, Integer> facMap;
static int sz;
static long min;
public static void main(String[] args) throws IOExcepti... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 7bd8b832216ae6d4b561d14bfdae6076 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class FactorialsandPowersofTwo {
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 58769a98213c1b32f6ba98c2ea2cb96c | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.Scanner;
import java.util.*;
public class Main {
public static void main(String[] args) {
var sc = new Scanner(System.in);
int n = Integer.parseInt(sc.next());
long max = (long) (1e12);
List<Long> f = new ArrayList();
long fact = 6;
int i... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | ba329b8cc212f295c825231deb684eb7 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.Scanner;
import java.util.*;
public class Main {
public static void main(String[] args) {
long max = (long) 1e12;
var sc = new Scanner(System.in);
int a = Integer.parseInt(sc.next());
List<Long> fact = new ArrayList();
for (long i = 3, factorial =... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 047a96a32c15e624c799fb3424d0cac4 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class JaiShreeRam{
static Scanner in=new Scanner();
static long systemTime;
static long mod = 1000000007;
static ArrayList<ArrayList<Integer>> adj;
static int seive[]=new int[1000001];
stati... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 2ac53c9cd4e983e3641e4248ea6b8e0d | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Codechef {
static boolean multipleTC = true;
final static int Mod = 1000000007;
final static int Mod2 = 998244353;
final double PI = 3.14159265358979323846;
int MAX = 1000000007;
void pre() throws Exception {
}
long cntBit(long n){
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 3af494689993813c3d07c057e02efe8e | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.Set;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | a877c663236850f81ead44240d9bd472 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | //package com.company;
import java.io.*;
import java.util.*;
public class Main {
public static List<Long> l;
public static class pair<T, E>{
T first;
E second;
pair(T first, E second){
this.first = first;
this.second = second;
}
void printPa... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | a925a4537ee3b7c9b804537bb892304a | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
static FastReader f = new FastReader();
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) {
int t = f.nextInt();
pre();
while(t-- > 0) {
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | a91df1769c02d887c00877fc9f75fd20 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Ex extends PrintWriter{
Ex() { super(System.out); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
Ex o = new Ex(); o.main(); o.flush();
}
int bitCount1(long n){
int ans=0;
while(n>0){
ans+=(n%2==0?0:1... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 9def1c54001802ce90eade21c9399046 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | // package div_2_774;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class C{
public static void main(String[] args){
FastReader sc = new FastReader();
int t=sc.nextInt();
while(t-->0){
long n = sc.nextLong();
long... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | d1d912152840c3ad49451d80af3c288b | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
//-------------------------------///////////////****/////////******//////////
//------------------------------------///**********//*****//********//*****//
//-----------------------------------///**********//*****//********//*****//
//---------... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | c3eef0d086dccbb699ca2b57b8b2b663 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Codeforces {
final static int mod = 1000000007;
public static void main(String[] args) throws Exception {
FastReader sc = new FastReader();
int t = sc.nextInt();
long[] fact = new long[16];
fact[1] = 1;
for... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 10c0dab5bdcd7cd1f69bc3b0a4a28bf3 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | /*
_oo0oo_
o8888888o
88" . "88
(| -_- |)
0\ = /0
___/`---'\___
.' \\| |// '.
/ \\||| : |||// \
/ _||||| -:- |||||- \
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | d14ff0a1c33da63d71b4a666431943bf | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static Scanner obj = new Scanner(System.in);
public static PrintWriter out = new PrintWriter(System.out);
public static int i() {
return obj.nextInt();
}
public static void main(String[] args) {
int len = i();
while (len-- !... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | b8acb765a843a82f5a08738331a01cc2 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Solution {
private final static FastReader scan = new FastReader();
static List<Integer> l1 = new ArrayList<>();
static HashMap<String,Integer> dp = new HashMap<>();
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | e01ca76e66e2728de7987713d04ed2f3 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;
import java.math.*;
public class C_Factorials_and_Powers_of_Two{
public static void main (String[] args){
try (Scanner s = new Scanner(System.in)) {
StringBuilder sb=new StringBuilder();
int t=1;t=s.nextInt();
for(int test=1;test<=t;test++){... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | fbb36d6d5eef4025f0c9372477f5df11 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes |
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.Math.PI;
import static java.lang.Math.min;
import static java.lang.System.arraycopy;
import static java.lang.System.exit;
import static java.util.Arrays.copyOf;
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 8a242a2c637b8bdc7a1bf968675ffebe | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes |
import java.util.*;
import java.math.*;
import java.io.*;
public class Solution {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 307a1c1333292a473cb18ac6d1773213 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.Math.sqrt;
import static java.lang.Math.pow;
import static java.lang.System.out;
import static java.lang.System.err;
import java.util.*;
import java.io.*;
import java.math.*;
public ... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 4e4d410aade30e54311dd65fef24d4df | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 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.*;
impor... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | c547755e0983c0ef8ab3b17034ed23be | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 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.*;
impor... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | b5900b2ac021e3a2c3aad2c57eb76c89 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes |
import java.io.*;
import java.util.*;
public class Main {
static MyScanner sc = new MyScanner();
static PrintWriter pw = new PrintWriter(System.out);
static int min = 1000;
public static void main(String[] args) throws Exception {
int fact = 2;
ArrayList<Long> al = new ArrayList<>();
al.... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | a7b284b9773e085b88a3594aa2776620 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;
public class Solution {
public static void main(String[] args) {
int t;
Scanner in= new Scanner(System.in);
t = in.nextInt();
while(t-- > 0) {
long n= in.nextLong();
HashMap<Long,Integer>map=new HashMap<>();
long[]fac=new long[15];fac[0]=1;
for(int i=1;i<15;i++) {
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | e45b3abdd8a5fd00403e4a3651533765 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes |
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 7abf73327cafa22f1cdb6d92ad596430 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | //package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Rough_Work {
private static long[] pre;
public static void main(String[] args) throws IOException {
FastReader sc = new FastReader();
PrintWriter out = new PrintWriter(System.out);
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 5aade39d7fb86b0a1c4d024c14f85dad | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Contest1646C
{
static class InputReader {
BufferedReader reader;
StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
token... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 4a799945a90293ee0cfb0398f2e070ff | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes |
// import java.io.*;
// import java.util.*;
// public class Main{
// static class FastReader {
// BufferedReader br;
// StringTokenizer st;
// public FastReader()
// {
// br = new BufferedReader(
// ... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 7ef50b733fb41307dd11d530853c2dae | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.*;
import java.util.*;
public class C {
public static void main(String[] args) {
factorials = new long[15];
factorials[0] = 1;
for (int i = 1; i < 15; i++) {
factorials[i] = factorials[i - 1] * i;
}
hs = new TreeMap<>();
HashMap<... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 0df192f37da2b0a38d41efe5265205d6 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;
/**
*
* @Har_Har_Mahadev
*/
/**
* Main , Solution , Remove Public
*/
public class C {
private static ArrayList<Long> set;
private st... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 4730bae7527f8d37f8df88cb0cbe9fb5 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
imp... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 374b294be145ed32e6b83ee9e91bc009 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class cf {
static PrintWriter pw = new PrintWriter(System.out);
public static void main(String[] args) throws IOException, InterruptedException {
Scanner sc = new Scanner(System.in);
long fac = 1;
int p = 2;
while (fac <= 1e12) {
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | ba1e79b5294330f3c49bd10ab3810c99 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;
import java.io.*;
public class C1646 {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
ArrayList<Long> fact = new ArrayList<>();
long cur = 6;
for ... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | b96f86714a3be7a02a66967e7beb2141 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class C_Factorials_and_Powers_of_Two {
static class FastScanner {
BufferedReader br=new BufferedReader(new InputS... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | e5979ab74ba9d4bae5397769a055a246 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;// hamare sath shri Raghunath, to kis baat ki chinta..........
import java.lang.*;// discipline is doing what needs to be done even if you don't want to do it.
import java.io.*;
public class a {
static FastReader sc = new FastReader();
static PrintWriter out = new PrintWriter(System.out)... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 529bd8a7a4557ba26e24053bebbb86d3 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
public class Main
{
static class Pair
{
long a,b;
public Pair(long a,long b)
{
this.a=a;
this.b=b;
}
// @Override
// public int compareTo(Pair p) {
// ... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 4524a6b7a02c094512b052bef8a51a21 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static final long mod = 998244353;
static PrintWriter out = new PrintWriter(System.out);
static FastScanner sc = new FastScanner();
static long nax = (long)1e12 + 100;
static ArrayList<Long> fact = new ArrayList<>();
static void solve() {
l... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | b3f0d9675233336ce2f218b006f2c891 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
public class Solution{
public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
static long MOD = (long) (1e9 + 7);
// static long MOD = 998244353;
static long inv2 = 499122177;
static long MOD2 = MOD * MOD;
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 99ffef0fb460805e9af245e0d3c0ad47 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.security.cert.X509CRL;
import java.util.*;
import java.lang.*;
import java.util.stream.Collector;
import java.util.stream.Co... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 6b7c90a4fd7a634cf66f0183dcd2899b | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes |
import java.io.*;
import java.util.*;
public class cp {
static int mod=(int)1e9+7;
// static Reader sc=new Reader();
static FastReader sc=new FastReader(System.in);
static int[] sp;
static int size=(int)1e6;
static int[] arInt;
static long[] arLong;
static long ans;
public static vo... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 21c632a0f1bb3a6af0fe20ad3a0b6de9 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
impor... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 5dbf5bc8ff3f1ce0c22d1d077e500b59 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class C {
static ArrayList<Long> facs = new ArrayList<>();
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(n... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | f910dafa7c83841ef9a6d2148a4e244d | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;
public class PowerOfTwo {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
StringBuffer str = new StringBuffer("");
long arr[] = new long[12];
long pow[] = new long[51];
pow[0] = 1;
for(int i = 1 ; i <= 50 ; i++) {
pow... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 5289a1f43201555368b2a64dca73ca7e | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | /*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
import java.util.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.i... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 758b51254616d2155b1f5bd338c402f2 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.*;
import java.lang.*;
import java.util.*;
public class Main {
public static int mod = (int) 1e9 + 7;
// **** -----> Disjoint Set Union(DSU) Start **********
public static int findPar(int node, int[] parent) {
if (parent[node] == node)
return node;
... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 11 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 50ded63016ea7e17c4e4ea063e068950 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes |
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main {
public static FastReader cin;
public static PrintWriter out;
public static void main(String[] args) throws Exception {
out = new PrintWriter(new BufferedOutputStream(Syste... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 17 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 44b9131d100c39a4c89398175b64ba67 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.*;
import java.util.function.*;
import java.io.*;
// you can compare with output.txt and expected out
public class Round774C {
MyPrintWriter out;
MyScanner in;
// final static long FIXED_RANDOM;
// static {
// FIXED_RANDOM = System.currentTimeMillis();
// }
final static String IMPO... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 17 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 2681932c02c3654187ba7dae0d9d2cee | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | /******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
***********************************************... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 17 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 3f7c68358ebe5c5e62b38c2849576d7e | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | /******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
***********************************************... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 17 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | cbf139bdc69d90cb287166d37873d725 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
import static java.lang.System.*;
import static java.util.Arrays.*;
import static java.util.stream.IntStream.iterate;
public class Te... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 17 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | e7339b8fef40ba766805d8efcdee6e0a | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes | import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int tc = 0; tc < t; ++tc) {
long n = sc.nextLong();
Sy... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 17 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | b4d87453dbf16d90f557e68022c82aa6 | train_110.jsonl | 1646408100 | A number is called powerful if it is a power of two or a factorial. In other words, the number $$$m$$$ is powerful if there exists a non-negative integer $$$d$$$ such that $$$m=2^d$$$ or $$$m=d!$$$, where $$$d!=1\cdot 2\cdot \ldots \cdot d$$$ (in particular, $$$0! = 1$$$). For example $$$1$$$, $$$4$$$, and $$$6$$$ are ... | 256 megabytes |
import java.util.*;
import java.io.*;
public class B {
static int countSetBits(long n){
int count = 0;
while(n>0){
n = n&(n-1);
count++;
}
return count;
}
static long fact(long n){
long fact = 1;
for(long i = 1;... | Java | ["4\n\n7\n\n11\n\n240\n\n17179869184"] | 3 seconds | ["2\n3\n4\n1"] | NoteIn the first test case, $$$7$$$ can be represented as $$$7=1+6$$$, where $$$1$$$ and $$$6$$$ are powerful numbers. Because $$$7$$$ is not a powerful number, we know that the minimum possible value of $$$k$$$ in this case is $$$k=2$$$.In the second test case, a possible way to represent $$$11$$$ as the sum of three ... | Java 17 | standard input | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp",
"math"
] | ff0b041d54755984df3706aae78d8ff2 | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. A test case consists of only one line, containing one integer $$$n$$$ ($$$1\le n\le 10^{12}$$$). | 1,500 | For each test case print the answer on a separate line. If $$$n$$$ can not be represented as the sum of distinct powerful numbers, print $$$-1$$$. Otherwise, print a single positive integer — the minimum possible value of $$$k$$$. | standard output | |
PASSED | 1c4dab41c8459a0435b774ef0290e77d | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | // package c1646;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | c4ea5a85d8de5c064c4c06f625518f39 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.lang.Math;
import java.nio.BufferOverflowException;
import java.util.*;
import java.io.*;
import java.lang.Math;
public final class code {
static int globalCnt = 0;
static int loss = 0;
/*
* static class sortCond implements Comparator<Pair<Integer, Integer>> {
*
* ... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | f348377e3d44303d81737836432729b2 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | // package cp_stuff.Codeforces_Problems;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
* yo
*/
public class yo {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 3967e7e18faf849c5c567ea9d3230f8f | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | // package cp_stuff.Codeforces_Problems;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// import java.io.PrintWriter;
/**
* yo
*/
public class yo {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 4694528be024ca547f19bd9ffb5ae8e9 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 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.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamW... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 197989339bac64c3308d73700666f8ab | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
static AReader scan = new AReader();
static int N = 200010;
static int M = N * 2;
static int[] h = new int[N];
static int[] e =... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | c9df7ed5ad6b67322583cb5f802f82d8 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | // JAI SHREE RAM, HAR HAR MAHADEV, HARE KRISHNA
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.*;
import java.lang.*;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.io.*;
public class CodeForces {
static private final String INPUT = "input.txt";
s... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 59db097e243a54f39324a8e60f78df14 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import javax.swing.text.Segment;
import java.util.*;
import java.io.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static java.util.stream.Collectors.toList;
public class Solution
{
private static class FastIO {
private static class FastReader
{
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | c63f76c33791fca8a40b54a9c4cb08e2 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Random;
import java.io.FileWriter;... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 88f06192cca6ed9bcfb4118a9af70c9c | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Random;
import java.util.Set;
import java.... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 60d7f1c7381699956bd4ee091fc5fc5f | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.util.*;
import java.io.*;
public class D1646 {
static ArrayList<Integer>[] adjList;
static int[][][] dp;
static int[] max(int[] a, int[] b) {
if (a[0] > b[0]) {
return a;
} else if (b[0] > a[0]) {
return b;
} else if (a[1] < b[1]) {
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 3a9eda96a5e5f6ab3d608f4a9ea1bbf7 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | //Utilities
import java.io.*;
import java.util.*;
public class a {
static int t;
static int n;
static ArrayList<Integer>[] adj;
static int u, v;
static Pair[][] dp;
static boolean[][] b;
static int[] res;
public static void main(String[] args) throws IOException {
t = 1;
outer : while (t-- ... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | c08d2948d33fb36af3f7d8d272c9804e | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.*;
import java.util.*;
public class new1{
static long mod = 1000000007;
public static long gcd(long a, long b)
{
if (a == 0)
return b;
return gcd(b%a, a);
}
public static int[] dfs1(ArrayList<ArrayList<Integer>> aList, int u, int v, int p, int[][][] dp)... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | b4667a2871e4e9a1a642b372323edbb8 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 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.*;
impor... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 3e01923c33064a88f84eaa842da7944c | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class C774D {
static StringBuffer ans1 = new StringBuffer("");
static FastScanner sc = new FastScanner();
static PrintWriter printWriter = new Print... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 531609d9f91fbbb5512f1704b144ec13 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.*;
import java.util.*;
public class WeightTheTree {
public static void solve(FastIO io) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
for (int i = 1; i < N; ++i) {
final int U = io.nextInt();
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | e629e0535f2e9e5c4713c45a5250935a | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.security.cert.X509CRL;
import java.util.*;
import java.lang.*;
import java.util.stream.Collector;
import java.util.stream.Co... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 3dc2af4b07061d009e492ebf36f1771f | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
public static void main(String[]args){
long s = System.currentTimeMillis();
new Solver().run();
System.err.println(System.currentTimeMillis()-s+"ms");
}
}
class Ans{
int score, ty... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 428558308c14c53eb7983b0fdb132c13 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.lang.Math;
import java.nio.BufferOverflowException;
import java.util.*;
import java.io.*;
import java.lang.Math;
public final class code {
static int globalCnt = 0;
static int loss = 0;
/*
* static class sortCond implements Comparator<Pair<Integer, Integer>> {
*
* ... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 4594d10ef9c126c4eba6254a95d40cae | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | bcc8bd69829060b9e0b6c97dfdb4ff21 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.util.*;
import java.io.*;
public class _1646_D {
static int n;
static ArrayList<Integer>[] tree;
static int[][][] dp;
static int[] res;
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | e54131ca9f93873c8756da8c508bd8ce | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 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.*;
impor... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 11 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 5e97d96ab1301f81f4ca3d036968e879 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.*;
import java.util.*;
public class WeightTheTree {
public static void solve(FastIO io) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
for (int i = 1; i < N; ++i) {
final int U = io.nextInt();
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 72d996606534597ff6c7035b08b95c30 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.*;
import java.util.*;
public class WeightTheTree {
public static void solve(FastIO io) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
for (int i = 1; i < N; ++i) {
final int U = io.nextInt();
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 39f15dc16322811813b33815f269eb43 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
public class WeightTheTree {
public static void solve(FastIO io) {
final int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
nodes[i] = new Node(i);
}
for (int i = 1; i < N; ++i) {
final int ... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | b113426e14fdb4f9d4ef11a733461b49 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.stream.IntStream;
public class Main implements Runnable {
InputReader in = new InputReader();
OutputWriter out = new OutputWriter();
static int[][] adj;
static int[][] maximumGoodVerticesInSubtree;
static long[][] minimumSubtreeSum;
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | c9bfce0ce9581411ebe761e2dd087a48 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | /*
Competitive Programming Template
*/
import static java.lang.Math.*;
import java.util.*;
import java.io.*;
import java.math.*;
public class x1646D
{
static int[][] edges;
public static void main(String hi[]) throws Exception
{
FastScanner infile = new FastScanner();
int N =... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | e1ec3841d51bb77c03b2d125cad3fe36 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | /*
Competitive Programming Template
*/
import static java.lang.Math.*;
import java.util.*;
import java.io.*;
import java.math.*;
public class x1646D
{
static int[][] edges;
public static void main(String hi[]) throws Exception
{
FastScanner infile = new FastScanner();
int N =... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 49c0ae57357c7d64c5c5f85796e03e7d | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | /*
Competitive Programming Template
*/
import static java.lang.Math.*;
import java.util.*;
import java.io.*;
import java.math.*;
public class x1646D
{
static ArrayDeque<Integer>[] edges;
public static void main(String hi[]) throws Exception
{
FastScanner infile = new FastScanner();
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 27c97a0e74c2cbcafe96c198a490a307 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | /*
Competitive Programming Template
*/
import static java.lang.Math.*;
import java.util.*;
import java.io.*;
import java.math.*;
public class x1646D
{
static ArrayDeque<Integer>[] edges;
public static void main(String hi[]) throws Exception
{
BufferedReader infile = new BufferedReader... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 52616fe92e83d0c614e18760b938ef2f | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | // package faltu;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.Map.Entry;
public class Main {
// ***********************MATHS--STARTS**************************... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 72d563182200b782a0d41c099c017880 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.Math;
public class Main {
public class MainSolution extends MainSolutionT {
// global vars
public void init(int tests_count){}
public class TestCase extends TestCaseT
{
int N;
int[] adj_count;
int[][] adj_l... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | a12fefcf77b4344908343e7973ea5ef6 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | e449084ecb4727b7aa1234cf0acb6fb3 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | accb97406a464c5f04f92afda7c10caa | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
//--------------------------INPUT READER---------------------------------//
static class fs {
public BufferedReader br;
StringTokenizer st = new StringTokenizer("");
public fs() { this(System.in); }
public fs(I... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 2f32646b0c141de55818576fe0c490e5 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.util.*;
import java.io.*;
public class D_Weight_the_Tree{
public static void solve(int a[],int n,int m){
}
public static void main(String args[])throws IOException{
Reader sc=new Reader();
int n=sc.nextInt();
Graph g=new Graph(n);
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | f3912a9d503c3f388be0c3edd6ad86f7 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | //make sure to make new file!
import java.io.*;
import java.util.*;
public class D774c{
public static ArrayList<ArrayList<Integer>> adj;
public static int[][] dp;
public static long[][] dpsum;
public static ArrayList<ArrayList<Integer>> paradj;
public static int[] answer;
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 529fcbb683dd4ef095c381446ad29c98 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.math.BigInteger;
public final class A
{
static PrintWriter out = new PrintWriter(System.out);
static StringBuilder ans=new StringBuilder();
static FastReader in=new FastReader();
// static int g[][];
static ArrayList<Int... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | fc9748495d9252fba7fc0a4eaa9d5d27 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.util.*;
import java.io.*;
// BEFORE 31ST MARCH 2022 !!
//MAX RATING EVER ACHIEVED-1622(LETS SEE WHEN WILL I GET TO CHANGE THIS)
////***************************************************************************
/* public class E_Gardener_and_Tree implements Runnable{
public static void ma... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 8c3875183cb6af7f94e651f4e0af14e8 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
int[][] edges = new int[n - 1][2];
for (int i = 0; i < n - 1; i++) {
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 46a6e4f5fbe9c672ada3255aef75dbaf | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import javafx.util.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output | |
PASSED | 4cbf07750287865292e86480a093a507 | train_110.jsonl | 1646408100 | You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. A tree is a connected undirected graph without cycles. For each $$$i=1,2, \ldots, n$$$, let $$$w_i$$$ be the weight of the $$$i$$$-th vertex. A vertex is called good if its weight is equal to the sum of the weights of all its neighbors.Initially... | 256 megabytes | import java.util.*;
import java.util.Map.Entry;
import java.math.*;
import java.io.*;
public class Main {
public static Node[] dpSpe;
public static Node[] dpNotSpe;
public static List<List<Integer>> g;
public static List<List<Integer>> tree;
public static int[] numEdges;
public static int[] weight;
public sta... | Java | ["4\n1 2\n2 3\n2 4", "3\n1 2\n1 3", "2\n1 2", "9\n3 4\n7 6\n2 1\n8 3\n5 6\n1 8\n8 6\n9 6"] | 2 seconds | ["3 4\n1 1 1 1", "2 3\n1 1 1", "2 2\n1 1", "6 11\n1 1 1 1 1 1 1 3 1"] | NoteThis is the tree for the first test case: In this case, if you assign a weight of $$$1$$$ to each vertex, then the good vertices (which are painted black) are $$$1$$$, $$$3$$$ and $$$4$$$. It impossible to assign weights so that all vertices are good vertices. The minimum sum of weights in this case is $$$1+1+1+... | Java 8 | standard input | [
"constructive algorithms",
"dfs and similar",
"dp",
"implementation",
"trees"
] | dc3848faf577c5a49273020a14b343e1 | The first line contains one integer $$$n$$$ ($$$2\le n\le 2\cdot 10^5$$$) — the number of vertices in the tree. Then, $$$n−1$$$ lines follow. Each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1\le u,v\le n$$$) denoting an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the edges form a tree. | 2,000 | In the first line print two integers — the maximum number of good vertices and the minimum possible sum of weights for that maximum. In the second line print $$$n$$$ integers $$$w_1, w_2, \ldots, w_n$$$ ($$$1\le w_i\le 10^9$$$) — the corresponding weight assigned to each vertex. It can be proven that there exists an ... | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.