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
3e63f9212aec12c6aec7d03e306b74a7
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.util.*; import java.io.*; public class Main { void solve (FastScanner in, PrintWriter out) { int n = in.nextInt(); int[] live = new int[2]; int[] dead = new int[2]; for (int i=0; i<n; i++) { int temp = in.nextInt(); if (temp == 1) { live[0] += in.nextInt(); dead[0] += in.nextInt...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 8
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
ef719fb7783931a2e4e0ecd5016ee12d
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in Actual solution is at the top * * @author viatsko */ public class Main { public static void main(String[] args) { InputStream inputStrea...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 8
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
e30a2b665f0c0fc9a9baa0028102d93e
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class SystemAdministrator { public static void main(String[] args) { // TODO Auto-generated method stub // Problem https://codeforces.com/problemset/problem/245/A Reader scan = ...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 8
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
80df013e8d73fcb473faa11412070350
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.util.Scanner; public class SystemAdministrator { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int reachedA= 0,lostA= 0,reachedB = 0,lostB = 0,ping; for(int i=0;i<n;i++) { ping = scan.nextInt(); i...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 8
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
1f3d59ca7a61a63054fa01a55fa6ad08
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int q=sc.nextInt(); int a=0,b=0; for(int i=1;i<=q;++i){ int t=sc.nextInt(),x=sc.nextInt(),y=sc.nextInt(); if(t==1){ a+=x-y; ...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 8
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
330ffffc79e2b9b9e24cfb7e6b754b15
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int q=sc.nextInt(); int a=0,b=0; for(int i=1;i<=q;++i){ if(sc.nextInt()==1){ a+=sc.nextInt()-sc.nextInt(); }else{ ...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 8
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
3b0da523bf702e71537fd8da5998c395
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.util.Scanner; public class SisAdmin { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int resplusOne = 0; int resminusOne = 0; int resplusTwo = 0; int resminusTwo = 0; for (int i = 0; i < n; i++) { int server ...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 8
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
71cb0497d9e495d3eac9a1a0f62f337d
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.util.Scanner; public class Administrator { public static void main(String[] args) { Scanner scanner = new Scanner (System.in); int n = scanner.nextInt(),r1=0,l1=0,r2=0,l2=0; for (int i=0;i<n;i++) { int z = scanner.nextInt();int x = scanner.nextInt();int y = scanner.nextInt(); if (z==1) {r1+=x;l1+=y;}...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 8
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
058f9b45c432a3790d4850b870b66cd8
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.util.Scanner; public class SystemAdministrator { public static void main(String[] args) { Scanner in = new Scanner(System.in); int count = in.nextInt(); int as = 0, af = 0, bs = 0, bf = 0; for (int i = 0; i < count; i++) { int p = in.nextInt(); i...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
04c94d649220a647fc55c4116595242a
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { /** * @param args * @throws IOException * @throws NumberFormatException */ public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader reader = ne...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
a1e4704dfbf1f166c5a7516086942895
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int a = 0, b = 0; int ta = 0, tb = 0; for (int i = 0; i < n; i++) { int t = in.nextInt(); if (t...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
e1eefc80bdef9cfa2a1e7247ce84f437
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.io.*; import java.util.*; public class SystemAdmin { public static void main(String[] args) throws IOException { //Scanner in = new Scanner(new File("Sample Input.txt")); Scanner in = new Scanner(System.in); StringBuilder out = new StringBuilder(); //while(in.hasNext...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
2644332ade86fb9b0b8c25da3aa60bb0
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class ProblemA { public static void main(String[] args) throws IOException { Problem...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
e4f090b3b7c3c297bc67038114296dc4
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public stat...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
52cd6fe7a616c2d6a2ac5df526ea4356
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
//package KROK_MBTU_Qualification; import java.util.*; import java.io.*; public class a { String input = ""; String output = ""; FastScanner in; PrintWriter out; void solve() throws Exception { int x1 = 0; int y1 = 0; int x2 = 0; int y2 = 0; int n = in.nextInt(); for (int i = 0; i<n; i++){ i...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
163ef3b94f1cd7dba42687ea17f07e2d
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.util.Scanner; public class SysAdmin { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a = 0, b = 0; int ai=0, bi=0; for(int i = 0; i < n; i++) { if(sc.nextInt() == 1) { ...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
b0febcced93678efd3d39ab68c7f6d46
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.util.Scanner; public class program { public static Scanner in = new Scanner(System.in); public static void main(String[] args) { int n = in.nextInt(); int numASuccess = 0; int numBSuccess = 0; int numAUnSuccess = 0; int numBUnSuccess = 0; for (int ...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
7b0a682f5af8a7e86713bcca42db255d
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.io.*; import java.util.*; public class Example { BufferedReader in; PrintWriter out; StringTokenizer st; String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(in.readLine()); } catch (Exception e) { ...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
923cbbcefa65a4b7abddacea6b26a893
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.io.*; import java.util.*; public class Example { BufferedReader in; PrintWriter out; StringTokenizer st; String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(in.readLine()); } catch (Exception e) { ...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
798dd181cce85621951348154b9d6c18
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
import java.util.*; import java.io.*; public class Main { private int T, A1, B1, A2, B2; public Integer nextInt(String s) { return Integer.valueOf(s); } public void output(int A1, int B1) { if (A1 < B1) { System.out.println("DEAD"); } else { System.out...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
33ceb61fa3e75eb6bbd3a235a0660f69
train_002.jsonl
1353339000
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program re...
256 megabytes
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.IOException; /** * * @author wijebandara */ public class Main { public static void main(String[] args)throws IOException { java.io.BufferedReader in =new java.io.BufferedReader(new j...
Java
["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0"]
2 seconds
["LIVE\nLIVE", "LIVE\nDEAD"]
NoteConsider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to t...
Java 6
standard input
[ "implementation" ]
1d8870a705036b9820227309d74dd1e8
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti =...
800
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes). In the second line print the state of server b in the similar format.
standard output
PASSED
69bbd65db90efb01b1f04c6800a995c2
train_002.jsonl
1589034900
For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"]
1 second
["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"]
null
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "math" ]
4bbb078b66b26d6414e30b0aae845b98
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 &gt; 0$$$). It is guaranteed that the answer f...
1,500
Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.
standard output
PASSED
f5e3e8906e4e3d85cb033f5cbe4a50ae
train_002.jsonl
1589034900
For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three ...
256 megabytes
import java.util.Scanner; public class F_1 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int tc = scanner.nextInt(); for (int t = 0; t < tc; t++) { StringBuilder sb = new StringBuilder(); int n0 = scanner.nextInt(); ...
Java
["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"]
1 second
["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"]
null
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "math" ]
4bbb078b66b26d6414e30b0aae845b98
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 &gt; 0$$$). It is guaranteed that the answer f...
1,500
Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.
standard output
PASSED
4ed9acd988bfcd72ca37170b9152179e
train_002.jsonl
1589034900
For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three ...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static int mod = (int)(Math.pow(10, 9) + 7); public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int t= sc.nextInt(); while (t--> 0){ int n1 ...
Java
["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"]
1 second
["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"]
null
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "math" ]
4bbb078b66b26d6414e30b0aae845b98
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 &gt; 0$$$). It is guaranteed that the answer f...
1,500
Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.
standard output
PASSED
c87f8c5e82a767d3980f96697a2fb93e
train_002.jsonl
1589034900
For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three ...
256 megabytes
//package com.company; import java.util.Scanner; public class CF_1252_F { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n0=sc.nextInt(); int n1=sc.nextInt(); int n2=sc.nextInt(); ...
Java
["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"]
1 second
["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"]
null
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "math" ]
4bbb078b66b26d6414e30b0aae845b98
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 &gt; 0$$$). It is guaranteed that the answer f...
1,500
Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.
standard output
PASSED
03ccf470ca61e2282e774680fec37ef2
train_002.jsonl
1589034900
For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three ...
256 megabytes
// Problem : F. Binary String Reconstruction // Contest : Codeforces - Codeforces Round #640 (Div. 4) // URL : https://codeforces.com/contest/1352/problem/F // Memory Limit : 256 MB // Time Limit : 1000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) import java.io.*; import java.util.*; public cla...
Java
["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"]
1 second
["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"]
null
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "math" ]
4bbb078b66b26d6414e30b0aae845b98
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 &gt; 0$$$). It is guaranteed that the answer f...
1,500
Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.
standard output
PASSED
c33b9975e7e3b1e7d098260c0c5ec14d
train_002.jsonl
1589034900
For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three ...
256 megabytes
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args)throws IOException{ InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String A = br.readLine(); int a,b,c,d,e,f; a = Integer.parseInt(A); for(b = ...
Java
["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"]
1 second
["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"]
null
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "math" ]
4bbb078b66b26d6414e30b0aae845b98
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 &gt; 0$$$). It is guaranteed that the answer f...
1,500
Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.
standard output
PASSED
2f9a40aea36af876e686793a463460c0
train_002.jsonl
1589034900
For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three ...
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.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"]
1 second
["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"]
null
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "math" ]
4bbb078b66b26d6414e30b0aae845b98
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 &gt; 0$$$). It is guaranteed that the answer f...
1,500
Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.
standard output
PASSED
f01ffce31f24274cfe031e0fa7dd7c50
train_002.jsonl
1589034900
For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three ...
256 megabytes
/*input 10 1 3 5 1 1 1 3 9 3 0 1 0 3 1 2 0 0 3 2 0 0 0 4 0 0 2 3 3 2 0 */ import java.util.*; public class Easy3{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(),n0,n1,n2,i; StringBuilder ans; while(t>0) { t--; ...
Java
["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"]
1 second
["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"]
null
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "math" ]
4bbb078b66b26d6414e30b0aae845b98
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 &gt; 0$$$). It is guaranteed that the answer f...
1,500
Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.
standard output
PASSED
6e17bdd9d7b69d2c2cb8dc5d8326a149
train_002.jsonl
1589034900
For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three ...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t-- > 0) { int n0 = in.nextInt(), n1 = in.nextInt(), n2 = in.nextInt(); StringBuilder sb = new StringBuilder(); if(n2...
Java
["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"]
1 second
["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"]
null
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "math" ]
4bbb078b66b26d6414e30b0aae845b98
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 &gt; 0$$$). It is guaranteed that the answer f...
1,500
Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.
standard output
PASSED
6177b45a047bccb630ba8f5277075626
train_002.jsonl
1589034900
For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three ...
256 megabytes
import java.util.Scanner; public class AZ { public static void main(String[] args) { Scanner cin= new Scanner(System.in); int t=cin.nextInt(); for (int i = 0; i <t; i++) { int zero=cin.nextInt(); int one=cin.nextInt(); int second=cin.nextInt(); StringBuilder str= new StringBuilder(); String...
Java
["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"]
1 second
["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"]
null
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "math" ]
4bbb078b66b26d6414e30b0aae845b98
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 &gt; 0$$$). It is guaranteed that the answer f...
1,500
Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.
standard output
PASSED
968ed1de0238d05bde7e006b2cf89e3f
train_002.jsonl
1589034900
For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three ...
256 megabytes
// package com.company; import java.util.*; import java.lang.*; import java.io.*; //****Use Integer Wrapper Class for Arrays.sort()**** public class CX6 { static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out)); public static void main(String[] Args){ FastReader scan=new FastReader();...
Java
["7\n1 3 5\n1 1 1\n3 9 3\n0 1 0\n3 1 2\n0 0 3\n2 0 0"]
1 second
["1110011110\n0011\n0110001100101011\n10\n0000111\n1111\n000"]
null
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "math" ]
4bbb078b66b26d6414e30b0aae845b98
The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 &gt; 0$$$). It is guaranteed that the answer f...
1,500
Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.
standard output
PASSED
6b77f1b29627dc025d8b217798f31c69
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.io.*; public class special { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t; t=Integer.parseInt(br.readLine()); while(t>0) { int l; l=Integer...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
cb44ddfc6bf1094b8fb5190d6b19d602
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Solution { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { int t = Integer.parseInt(br.readLine()); ...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
771159d095115c0d85307c2e09b2ae2e
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; public class SpecialPermutations { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- >0) { int n = sc.nextInt(); int arr[] = new int[n]; for(int i=2;i<=n;i++) { System.out.print(i + " "); } System.out.printl...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
7c081761668eda5fd589f73bb9050ab0
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; public class Main{ public static void main(String []args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int p=n; int []arr=new int[n]; for(int i=0;i<p;i++){ arr[i]=n; n--; } for(int i=0;i<p;i++){ if(arr[i]==i+1){ int temp=arr[i]; arr[i]=arr[i+1]; arr[i+1]...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
6bff8a3a08a5badd7d9a45f7f3ac24c6
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; public class problems { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t>0) { int n=sc.nextInt(); solve(n); System.out.println(); t--; } } static void solve(int n) { for(int i=2;i<=n;i++) { System.out.print(i+" ");...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
8a1138532960751d7da3d75f0fb7372a
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; import java.math.*; public class A { static boolean isprime(int n) { for(int i=2;i<=Math.sqrt(n);i++) if(n%i==0) return false; return true; } public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int t,n,i,j,sum=0,c=0,k,...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
8c9aacc8c53a93b9c21a26a6bd6e2861
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; public class Main { private static void solve() {} public static void main(String[] args) { int t = scanner.nextInt(); for (int i = 0; i < t; i++) { int n = scanner.nextInt(); List<String> list = new ArrayList<>(); for (int j = n, k = 0; j >= 1; j--, k++) { i...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
751aaf962257695f8442b25b528d93df
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class FirstPage { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t > 0) { int n=sc.nextInt(); ArrayList<Integer> al...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
ab80cc36316fa031d91cbd11df40149c
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ public static void main(String[] args) throws IOException{ Scanner sc = new Scanner(System.in); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int t = sc.nextInt(); while(t-- > 0){ ...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
648becdc59fb8cdd37e6a124a6ecf809
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; public class MyClass { public static void main(String args[]) { Scanner s = new Scanner(System.in); int t = s.nextInt(); for(int i=0;i<t;i++){ int n = s.nextInt(); int[] arr = new int[n]; for(int j=n-1;j>=0;j--){ arr[j]=...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
c248e9f67c19ec841acb6de0960d7557
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; public class SpecialPermutation { static Scanner sc = new Scanner(System.in); public static void main(String arg[]) { int t = sc.nextInt(); for(int i=0; i<t; i++) { solve(); } } static void solve() { int n = sc.nextInt(); if(n%2 == 0) { for(int i=n; i>=1; i--) { System.out.pr...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
667e370477e2f2b9eb896ea897110408
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t=scan.nextInt(); while(t-->0){ int n=scan.nextInt(); int arr[]= new int[n+1]; if(n>1){ ...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
407543073d592bcb75540432e0758acf
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; public class Sol { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n; n = sc.nextInt(); for (int i=0;i<n-1;i++){ System.out.print((i+2)+" "); } System.out.println(1+" "); } } }
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
05449d32cdda970b05b13bca161ac89e
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static void main(String [] args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int n [] = new int[a]; for (int i = 0; i < a; i ++){ n[i] = sc.nextInt(); } ...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
21a8ec578e5824bf8526318be87f7805
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; public class Solution { public static void main(String [] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); while(t-->0) { int n = scan.nextInt(); int a[] = new int[n]; for(int i=1;i<=n;i++) a[i-1]=i; for(int i=0;i<n-1;i++) { int x=a[i]; a[i]=a[i+1]; a[i+1]=x; } for(in...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
8b6627371906a6b3037fb3a4d84e7005
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.io.*; import java.util.*; public class Prb2 { static PrintWriter pw; static Scanner sc; static void print(final String arg) { pw.write(arg); pw.flush(); } static void runFile() throws Exception { sc = new Scanner(new FileReader("input.txt")); pw = ...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
6d3a9b855d55e9ea0656ee51afb6eb9d
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int T = in.nextInt(); while(--T >= 0) { int N = in.nextInt(); for(int i = 0; i < N / 2; i++) { System.out.print((N - i) +...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
7ba601181580adbf8c8a3b746829746e
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.Scanner; public class Main { public static void main (String [] args) throws Exception{ Scanner input = new Scanner(System.in); int n = input.nextInt(); while (n-- != 0) { int m = input.nextInt(); for (int i = 2; i <= m ; i++) { System.out.print(i + " "); } System.out.println(...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
5625adf5708cce98e7330d31f8cb8fcb
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.io.*; import java.util.*; public class SpecialPermutation { static final Scanner in = new Scanner(System.in); public static void main(String[] args) { int t=in.nextInt(); for (int i=1; i<=t; ++i) { new Solver(); } in.close(); } static class Solver { Solver() { int n = in.nextInt(); ...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
b1a055362794ca146f3c70418b5ef6a2
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.Scanner; public class A686 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); if(n%2==0) { for(int i=n;i>0;i--) System.out.print(i+" "); } else { for(int i=n;...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
5a5fe7d8e43a6f29e5c2d882789a5179
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.math.*; import java.io.*; import java.util.*; public class test { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); for(int i = 1 ; i<n;i++) { System.out.print(i+1 +" "); ...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
8baa0ef4ae439475bc317db62767c263
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.*; import java.io.*; public class Solution { private static FastReader in = new FastReader(); public static void main(String[] args) throws Exception { int t = in.nextInt(); while (t-- > 0) { solve(); } } static void solve() { int n = in.n...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
3737ca8c6f9d9794610d0cfa0791e25a
train_002.jsonl
1606228500
You are given one integer $$$n$$$ ($$$n &gt; 1$$$).Recall that a permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2, 3, 1, 5, 4]$$$ is a permutation of length $$$5$$$, but $$$[1, 2, 2]$$$ is not a permutation ($$$2$$$ appears ...
256 megabytes
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.Set; public class CodeForces { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); ...
Java
["2\n2\n5"]
1 second
["2 1\n2 1 5 3 4"]
null
Java 11
standard input
[ "constructive algorithms", "probabilities" ]
f4779e16e0857e6507fdde55e6d4f982
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the length of the permutation you have to find.
null
For each test case, print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ — a permutation that there is no index $$$i$$$ ($$$1 \le i \le n$$$) such that $$$p_i = i$$$ (so, for all $$$i$$$ from $$$1$$$ to $$$n$$$ the condition $$$p_i \ne i$$$ should be satisfied). If there are several answers, you can print any. I...
standard output
PASSED
46adcc2e3dd2f508c91f3a835ec050f1
train_002.jsonl
1559399700
Arkady bought an air ticket from a city A to a city C. Unfortunately, there are no direct flights, but there are a lot of flights from A to a city B, and from B to C.There are $$$n$$$ flights from A to B, they depart at time moments $$$a_1$$$, $$$a_2$$$, $$$a_3$$$, ..., $$$a_n$$$ and arrive at B $$$t_a$$$ moments later...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner( System.in ); int ans = 0; int number1 = in.nextInt(); int number2 = in.nextInt(); int time1 = in.nextInt(); int time2 = in.nextInt(); int k = in.nextInt(); int array1[] = new int...
Java
["4 5 1 1 2\n1 3 5 7\n1 2 3 9 10", "2 2 4 4 2\n1 10\n10 20", "4 3 2 3 1\n1 999999998 999999999 1000000000\n3 4 1000000000"]
1 second
["11", "-1", "1000000003"]
NoteConsider the first example. The flights from A to B depart at time moments $$$1$$$, $$$3$$$, $$$5$$$, and $$$7$$$ and arrive at B at time moments $$$2$$$, $$$4$$$, $$$6$$$, $$$8$$$, respectively. The flights from B to C depart at time moments $$$1$$$, $$$2$$$, $$$3$$$, $$$9$$$, and $$$10$$$ and arrive at C at time ...
Java 11
standard input
[ "two pointers", "binary search", "brute force" ]
bf60899aa2bd7350c805437d0fee1583
The first line contains five integers $$$n$$$, $$$m$$$, $$$t_a$$$, $$$t_b$$$ and $$$k$$$ ($$$1 \le n, m \le 2 \cdot 10^5$$$, $$$1 \le k \le n + m$$$, $$$1 \le t_a, t_b \le 10^9$$$) — the number of flights from A to B, the number of flights from B to C, the flight time from A to B, the flight time from B to C and the nu...
1,600
If you can cancel $$$k$$$ or less flights in such a way that it is not possible to reach C at all, print $$$-1$$$. Otherwise print the earliest time Arkady can arrive at C if you cancel $$$k$$$ flights in such a way that maximizes this time.
standard output
PASSED
696146f63c0b175627c1844a68f1740c
train_002.jsonl
1605450900
You have a knapsack with the capacity of $$$W$$$. There are also $$$n$$$ items, the $$$i$$$-th one has weight $$$w_i$$$. You want to put some of these items into the knapsack in such a way that their total weight $$$C$$$ is at least half of its size, but (obviously) does not exceed it. Formally, $$$C$$$ should satisfy:...
256 megabytes
import java.util.*; import java.io.*; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new Da...
Java
["3\n1 3\n3\n6 2\n19 8 19 69 9 4\n7 12\n1 1 1 17 1 1 1"]
2 seconds
["1\n1\n-1\n6\n1 2 3 5 6 7"]
NoteIn the first test case, you can take the item of weight $$$3$$$ and fill the knapsack just right.In the second test case, all the items are larger than the knapsack's capacity. Therefore, the answer is $$$-1$$$.In the third test case, you fill the knapsack exactly in half.
Java 11
standard input
[ "constructive algorithms", "sortings", "greedy", "math" ]
afe8710473db82f8d53d28dd32646774
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). Description of the test cases follows. The first line of each test case contains integers $$$n$$$ and $$$W$$$ ($$$1 \le n \le 200\,000$$$, $$$1\le W \le 10^{18}$$$). The second line of each test c...
1,300
For each test case, if there is no solution, print a single integer $$$-1$$$. If there exists a solution consisting of $$$m$$$ items, print $$$m$$$ in the first line of the output and $$$m$$$ integers $$$j_1$$$, $$$j_2$$$, ..., $$$j_m$$$ ($$$1 \le j_i \le n$$$, all $$$j_i$$$ are distinct) in the second line of the out...
standard output
PASSED
e1aff9aca5f36a3927c4463c7bc25e4a
train_002.jsonl
1605450900
You have a knapsack with the capacity of $$$W$$$. There are also $$$n$$$ items, the $$$i$$$-th one has weight $$$w_i$$$. You want to put some of these items into the knapsack in such a way that their total weight $$$C$$$ is at least half of its size, but (obviously) does not exceed it. Formally, $$$C$$$ should satisfy:...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); int t=Integer.parseInt(bu.readLine()); while(t--...
Java
["3\n1 3\n3\n6 2\n19 8 19 69 9 4\n7 12\n1 1 1 17 1 1 1"]
2 seconds
["1\n1\n-1\n6\n1 2 3 5 6 7"]
NoteIn the first test case, you can take the item of weight $$$3$$$ and fill the knapsack just right.In the second test case, all the items are larger than the knapsack's capacity. Therefore, the answer is $$$-1$$$.In the third test case, you fill the knapsack exactly in half.
Java 11
standard input
[ "constructive algorithms", "sortings", "greedy", "math" ]
afe8710473db82f8d53d28dd32646774
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). Description of the test cases follows. The first line of each test case contains integers $$$n$$$ and $$$W$$$ ($$$1 \le n \le 200\,000$$$, $$$1\le W \le 10^{18}$$$). The second line of each test c...
1,300
For each test case, if there is no solution, print a single integer $$$-1$$$. If there exists a solution consisting of $$$m$$$ items, print $$$m$$$ in the first line of the output and $$$m$$$ integers $$$j_1$$$, $$$j_2$$$, ..., $$$j_m$$$ ($$$1 \le j_i \le n$$$, all $$$j_i$$$ are distinct) in the second line of the out...
standard output
PASSED
171111868e4200c1f0db35b52003fac6
train_002.jsonl
1605450900
You have a knapsack with the capacity of $$$W$$$. There are also $$$n$$$ items, the $$$i$$$-th one has weight $$$w_i$$$. You want to put some of these items into the knapsack in such a way that their total weight $$$C$$$ is at least half of its size, but (obviously) does not exceed it. Formally, $$$C$$$ should satisfy:...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static Reader sc = new Reader(); //public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static int max(int x, int y) { return x > y ? x:y; } static class Pair implements Comparable<Pair>{ int x; long y; p...
Java
["3\n1 3\n3\n6 2\n19 8 19 69 9 4\n7 12\n1 1 1 17 1 1 1"]
2 seconds
["1\n1\n-1\n6\n1 2 3 5 6 7"]
NoteIn the first test case, you can take the item of weight $$$3$$$ and fill the knapsack just right.In the second test case, all the items are larger than the knapsack's capacity. Therefore, the answer is $$$-1$$$.In the third test case, you fill the knapsack exactly in half.
Java 11
standard input
[ "constructive algorithms", "sortings", "greedy", "math" ]
afe8710473db82f8d53d28dd32646774
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). Description of the test cases follows. The first line of each test case contains integers $$$n$$$ and $$$W$$$ ($$$1 \le n \le 200\,000$$$, $$$1\le W \le 10^{18}$$$). The second line of each test c...
1,300
For each test case, if there is no solution, print a single integer $$$-1$$$. If there exists a solution consisting of $$$m$$$ items, print $$$m$$$ in the first line of the output and $$$m$$$ integers $$$j_1$$$, $$$j_2$$$, ..., $$$j_m$$$ ($$$1 \le j_i \le n$$$, all $$$j_i$$$ are distinct) in the second line of the out...
standard output
PASSED
1422350a2776af7f1424fe02162c1499
train_002.jsonl
1605450900
You have a knapsack with the capacity of $$$W$$$. There are also $$$n$$$ items, the $$$i$$$-th one has weight $$$w_i$$$. You want to put some of these items into the knapsack in such a way that their total weight $$$C$$$ is at least half of its size, but (obviously) does not exceed it. Formally, $$$C$$$ should satisfy:...
256 megabytes
import java.util.*; public class c { static Scanner in = new Scanner(System.in); public static void main(String[] args) { int t = in.nextInt(); while(t-- > 0) { int n = in.nextInt(); long w = in.nextLong(); long h = w/2; if(w%2==1) h++; Vertex[] a = new Vertex[n]; List<Inte...
Java
["3\n1 3\n3\n6 2\n19 8 19 69 9 4\n7 12\n1 1 1 17 1 1 1"]
2 seconds
["1\n1\n-1\n6\n1 2 3 5 6 7"]
NoteIn the first test case, you can take the item of weight $$$3$$$ and fill the knapsack just right.In the second test case, all the items are larger than the knapsack's capacity. Therefore, the answer is $$$-1$$$.In the third test case, you fill the knapsack exactly in half.
Java 11
standard input
[ "constructive algorithms", "sortings", "greedy", "math" ]
afe8710473db82f8d53d28dd32646774
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). Description of the test cases follows. The first line of each test case contains integers $$$n$$$ and $$$W$$$ ($$$1 \le n \le 200\,000$$$, $$$1\le W \le 10^{18}$$$). The second line of each test c...
1,300
For each test case, if there is no solution, print a single integer $$$-1$$$. If there exists a solution consisting of $$$m$$$ items, print $$$m$$$ in the first line of the output and $$$m$$$ integers $$$j_1$$$, $$$j_2$$$, ..., $$$j_m$$$ ($$$1 \le j_i \le n$$$, all $$$j_i$$$ are distinct) in the second line of the out...
standard output
PASSED
b067280d9aa5c0bfef8ccf2b4189c271
train_002.jsonl
1605450900
You have a knapsack with the capacity of $$$W$$$. There are also $$$n$$$ items, the $$$i$$$-th one has weight $$$w_i$$$. You want to put some of these items into the knapsack in such a way that their total weight $$$C$$$ is at least half of its size, but (obviously) does not exceed it. Formally, $$$C$$$ should satisfy:...
256 megabytes
import java.util.*; import java.io.*; public class Solution { static class Reader { BufferedReader br; StringTokenizer st; public Reader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringT...
Java
["3\n1 3\n3\n6 2\n19 8 19 69 9 4\n7 12\n1 1 1 17 1 1 1"]
2 seconds
["1\n1\n-1\n6\n1 2 3 5 6 7"]
NoteIn the first test case, you can take the item of weight $$$3$$$ and fill the knapsack just right.In the second test case, all the items are larger than the knapsack's capacity. Therefore, the answer is $$$-1$$$.In the third test case, you fill the knapsack exactly in half.
Java 11
standard input
[ "constructive algorithms", "sortings", "greedy", "math" ]
afe8710473db82f8d53d28dd32646774
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). Description of the test cases follows. The first line of each test case contains integers $$$n$$$ and $$$W$$$ ($$$1 \le n \le 200\,000$$$, $$$1\le W \le 10^{18}$$$). The second line of each test c...
1,300
For each test case, if there is no solution, print a single integer $$$-1$$$. If there exists a solution consisting of $$$m$$$ items, print $$$m$$$ in the first line of the output and $$$m$$$ integers $$$j_1$$$, $$$j_2$$$, ..., $$$j_m$$$ ($$$1 \le j_i \le n$$$, all $$$j_i$$$ are distinct) in the second line of the out...
standard output
PASSED
7ea5a1c0f9df368214492d9a75dd467e
train_002.jsonl
1605450900
You have a knapsack with the capacity of $$$W$$$. There are also $$$n$$$ items, the $$$i$$$-th one has weight $$$w_i$$$. You want to put some of these items into the knapsack in such a way that their total weight $$$C$$$ is at least half of its size, but (obviously) does not exceed it. Formally, $$$C$$$ should satisfy:...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class C { final static int MAXN = 100_005; final static long MOD = (long) 1e9 + 7; public static void main(String[] args) { FastScanner sc = new FastScanner(); int t = sc.nextInt(); outer...
Java
["3\n1 3\n3\n6 2\n19 8 19 69 9 4\n7 12\n1 1 1 17 1 1 1"]
2 seconds
["1\n1\n-1\n6\n1 2 3 5 6 7"]
NoteIn the first test case, you can take the item of weight $$$3$$$ and fill the knapsack just right.In the second test case, all the items are larger than the knapsack's capacity. Therefore, the answer is $$$-1$$$.In the third test case, you fill the knapsack exactly in half.
Java 11
standard input
[ "constructive algorithms", "sortings", "greedy", "math" ]
afe8710473db82f8d53d28dd32646774
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). Description of the test cases follows. The first line of each test case contains integers $$$n$$$ and $$$W$$$ ($$$1 \le n \le 200\,000$$$, $$$1\le W \le 10^{18}$$$). The second line of each test c...
1,300
For each test case, if there is no solution, print a single integer $$$-1$$$. If there exists a solution consisting of $$$m$$$ items, print $$$m$$$ in the first line of the output and $$$m$$$ integers $$$j_1$$$, $$$j_2$$$, ..., $$$j_m$$$ ($$$1 \le j_i \le n$$$, all $$$j_i$$$ are distinct) in the second line of the out...
standard output
PASSED
8796dbdc111454aae253149106ba9404
train_002.jsonl
1605450900
You have a knapsack with the capacity of $$$W$$$. There are also $$$n$$$ items, the $$$i$$$-th one has weight $$$w_i$$$. You want to put some of these items into the knapsack in such a way that their total weight $$$C$$$ is at least half of its size, but (obviously) does not exceed it. Formally, $$$C$$$ should satisfy:...
256 megabytes
//============================================================================ /* "There is nothing that can take the pain away. But eventually you will find a way to live with it. There will be nightmares. And every day when you wake up, it will be the first thing you think about. Until one day, it...
Java
["3\n1 3\n3\n6 2\n19 8 19 69 9 4\n7 12\n1 1 1 17 1 1 1"]
2 seconds
["1\n1\n-1\n6\n1 2 3 5 6 7"]
NoteIn the first test case, you can take the item of weight $$$3$$$ and fill the knapsack just right.In the second test case, all the items are larger than the knapsack's capacity. Therefore, the answer is $$$-1$$$.In the third test case, you fill the knapsack exactly in half.
Java 11
standard input
[ "constructive algorithms", "sortings", "greedy", "math" ]
afe8710473db82f8d53d28dd32646774
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). Description of the test cases follows. The first line of each test case contains integers $$$n$$$ and $$$W$$$ ($$$1 \le n \le 200\,000$$$, $$$1\le W \le 10^{18}$$$). The second line of each test c...
1,300
For each test case, if there is no solution, print a single integer $$$-1$$$. If there exists a solution consisting of $$$m$$$ items, print $$$m$$$ in the first line of the output and $$$m$$$ integers $$$j_1$$$, $$$j_2$$$, ..., $$$j_m$$$ ($$$1 \le j_i \le n$$$, all $$$j_i$$$ are distinct) in the second line of the out...
standard output
PASSED
991668de0ba9231e66ce987fab8ee5bb
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
// Working program with FastReader import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { ...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
d2cf83b52dde4e8bdd1b9557f0f65854
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
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 { public static void main(String[] args) throws IOException { FastReader read = new FastReader(); StringBuilder out = new StringB...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
ad5941fd7dac939c1ca1c057a70af0e1
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Jenish */ public class Ma...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
010c6dd7da1904390409ca810a5ae008
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.*; import java.io.*; import java.text.DecimalFormat; public class Exam { public static long mod = (long)Math.pow(10, 9)+7 ; public static double epsilon=0.00000000008854;//value of epsilon public static InputReader sc = new InputReader(System.in); public static PrintWriter pw = new PrintWriter(Syst...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
e4c4ba3ba5a1ab627c0ad842b93f72c4
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.*; public class simple { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int t=scan.nextInt(); while(t>0) { int n=scan.nextInt(); int i; int m=scan.nextInt(); int [] a=new int [n]; long sum=0; for(i=0;i<n;i++) { a[i]=scan.nextInt(); sum=sum+a[i]; } ...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
1e18273b5b4cc525805fb3de6515dd25
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static int cost = 0; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
ea0686098b77176108f2ae0b6889764e
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.*; import java.util.*; public class GFG { public static void main (String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while (t-->0) { int n=sc.nextInt(); int m=sc.nextInt(); int arr[]=new int[n]; for(int i=0;i<n;i++) arr[i]=sc.nextInt(); ...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
e85d70eebfe8e27965dd21de0edbef74
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.Objects; import java.util.List; import java.util.StringTokenizer; import j...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
6efcda5195646b672dcd68d817a8e58a
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
2f9ca31a79a8a3e13802a26154099677
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.util.Deque; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.Objects; import java.util...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
8d58c4c251944a79ed101ed9117a3c26
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.Scanner; public class div601B { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int t=sc.nextInt(); for(int z=0;z<t;z++) { int flag=0; int n=sc.nextInt(); int chain=sc.nextInt(); int sum=0; for(int i=1;i<=n;i+...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
e9894dde1091e21019aea90880421005
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.*; public class Solution{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); int m = sc.nextInt(); int[] w = new int[n]; int cost = 0; for(int i=0;i...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
1eafbdc0d29ad9990b4040b3c27b19d8
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.*; import java.util.*; public class Main { static boolean prime[]; public static void main(String ag[]) { Scanner sc=new Scanner(System.in); int i,j,k; int T=sc.nextInt(); while(T-- >0) { int N=sc.nextInt(); int M=sc.nextInt...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
9bace666fbd0353d5b06158e17af33ed
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Q2 { public static void main(String[] args) { mYScanner in = new mYScanner(); int t = in.nextInt(); for(int i = 0;i<t;i++) { int n = in.nextInt(); int m = in....
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
94741eefa393d3f108e4ed472cb30016
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.*; import java.util.*; public class HelloWorld{ static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } Str...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
06f85eb08059d5f6ae95e22153536e7d
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Day9 { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(System.out); int T = Integer....
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
80749fcb25d930594df16f3642ff9c40
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; public class Main { // static Scanner scanner = new Scanner(System.in); // static BufferedReader scanner=new BufferedReader(new InputStreamReader(System.in)); // static PrintWriter writer = new PrintWriter(System.out); ...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
6d85c63915fd50e0c0b029652e6caecb
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.*; public final class FridgeLockersB { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t-->0) { int n = in.nextInt(); int m = in.nextInt(); int arr[] = new int[...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
bf706b1f1dba374e79cc4be0acddae58
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.*; import java.util.*; public class div2601b { static int[] arr = new int[1001]; static LinkedList<Integer> adj[] = new LinkedList[1001]; public static void main(String[] args) throws Exception { for (int i = 1; i <= 1000; i++) { adj[i] = new LinkedList<>(); for (int j = 1 ; j <+ 1000;j++) ...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
32cb36d1e107dde1b055f24e2f7322f5
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); ...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
a96e39e50830606f0afcca8ce20208c5
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.Scanner; public class CodeForces601B { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int T = scanner.nextInt(); for (int i = 0; i < T; i++) { int n = scanner.nextInt(); int m = scanner.nextInt(); int a...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
7849e7a48e3f505f6a483789f7e3c76b
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.Scanner; import java.util.Collections; import java.util.ArrayList; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { pub...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
95f39a69f2176404444afd126f0a1f6d
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; 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.HashSet; import java.util.LinkedList; import ...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
2ae20473ff681c219d2f3cd48b0551e1
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.math.BigInteger; import java.util.LinkedList; import java.util.Queue; public final class C { static StringBuilder ans=new StringBuilder(); static FastReader in=new FastReader(); static ArrayList<ArrayList<Integer>> g; static lon...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
d1ccb6c6519a85d92c556aecde68b2b5
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); for(int i=0;i<t;i++) { int n=s.nextInt(); int m=s.nextInt(); hold[...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
a0e5ac10eef878423680274c29469e34
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner Sc=new Scanner(System.in); int T=Sc.nextInt(); for(int i=0;i<T;i++) { int n=Sc.nextInt(); int m=Sc.nextInt(); int a[]=new int[n]; int sum=...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
2e426d01b6a937620f4178d3fd9a99d5
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.*; public class square { public static void main(String ar[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int k=1;k<=t;k++) { int n=sc.nextInt(),m=sc.nextInt(); int[] weights=new int[n+1]; for(int i=1;i<=n;i++)weights[i]=sc....
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
fd08f3c34575bd9219820efb1ab3814f
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.*; public class Mohammad { public static class xy{ int x; int y; xy(int x, int y){ this.x = x; this.y = y;} } public static void Mohammad_AboHasan(){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n =...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
bfa156b1a492f19c3ab499bd890415f2
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.*; public class b { static int mod = (int) 1e9 + 7; static int Infinity=Integer.MAX_VALUE; static int negInfinity=Integer.MIN_VALUE; public static void main(String args[]) { try { Scanner d= new Scanner(System.in); int t,i,n,j,m,s,k; ...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
64fe4bcf8255cb64323ec4a82e7a9512
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.util.*; public class Solutions { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int test=sc.nextInt(); while(test>0) { int n=sc.nextInt(); int m=sc.nextInt(); int arr[]=new int [n]; for(int i=0;i<n;i++) { arr[i]=sc.nextInt(...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
68a7a4dbece7a20edc9055fbf5f392ad
train_002.jsonl
1574174100
Hanh lives in a shared apartment. There are $$$n$$$ people (including Hanh) living there, each has a private fridge. $$$n$$$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all chains connected to i...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.InputMismatchException; ///import ChangingVolums.InputReader; public class FridgeLocks { public static void main(String[] args) { // TODO Auto-generated method stub InputReader input =new InputReader(System.in); int t = input.nextInt...
Java
["3\n4 4\n1 1 1 1\n3 1\n1 2 3\n3 3\n1 2 3"]
1 second
["8\n1 2\n4 3\n3 2\n4 1\n-1\n12\n3 2\n1 2\n3 1"]
null
Java 8
standard input
[ "implementation", "graphs" ]
f6e219176e846b16c5f52dee81601c8e
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10$$$). Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$2 \le n \le 1000$$$, $$$1 \le m \le n$$$) — the number of people living in ...
1,100
For each test case: If there is no solution, print a single integer $$$-1$$$. Otherwise, print a single integer $$$c$$$ — the minimum total cost. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$), meaning that the $$$i$$$-th steel c...
standard output
PASSED
e7ce698aef2f862ae6da57983150aad4
train_002.jsonl
1554550500
You have received your birthday gifts — $$$n$$$ triples of integers! The $$$i$$$-th of them is $$$\lbrace a_{i}, b_{i}, c_{i} \rbrace$$$. All numbers are greater than or equal to $$$0$$$, and strictly smaller than $$$2^{k}$$$, where $$$k$$$ is a fixed integer.One day, you felt tired playing with triples. So you came up...
256 megabytes
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.charset.Charset; import java.util.Arrays; public class CF1119H { public static void main(String[] args) throws Exception { boolean local = System.getProperty("ONLINE_JUDGE"...
Java
["1 1\n1 2 3\n1 0 1", "2 2\n1 2 1\n0 1 2\n1 2 3", "4 3\n1 2 3\n1 3 7\n0 2 5\n1 0 6\n3 3 2"]
1.5 seconds
["2 4", "4 2 4 6", "198 198 126 126 126 126 198 198"]
NoteIn the first example, the array we formed is $$$(1, 0, 0, 1, 1, 1)$$$, we have two choices to get $$$0$$$ as the XOR and four choices to get $$$1$$$.In the second example, two arrays are $$$(0, 1, 1, 2)$$$ and $$$(1, 2, 2, 3)$$$. There are sixteen $$$(4 \cdot 4)$$$ choices in total, $$$4$$$ of them ($$$1 \oplus 1$$...
Java 8
standard input
[ "math", "fft" ]
379a57ff01d337203bc2fc2cf9f63508
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 10^{5}$$$, $$$1 \leq k \leq 17$$$) — the number of arrays and the binary length of all numbers. The second line contains three integers $$$x$$$, $$$y$$$, $$$z$$$ ($$$0 \leq x,y,z \leq 10^{9}$$$) — the integers you chose. Then $$$n$$$ lines follo...
3,200
Print a single line containing $$$2^{k}$$$ integers. The $$$i$$$-th of them should be the number of ways to choose exactly one integer from each array so that their XOR is equal to $$$t = i-1$$$ modulo $$$998244353$$$.
standard output
PASSED
43d744df624f9f128ff4d8c7a5c9bfcd
train_002.jsonl
1554550500
You have received your birthday gifts — $$$n$$$ triples of integers! The $$$i$$$-th of them is $$$\lbrace a_{i}, b_{i}, c_{i} \rbrace$$$. All numbers are greater than or equal to $$$0$$$, and strictly smaller than $$$2^{k}$$$, where $$$k$$$ is a fixed integer.One day, you felt tired playing with triples. So you came up...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class cfGlobal2H { static final int P = 998244353; static final int INV2 = (P + 1) / 2; void fwhtMod(int[] a) { int n = a.length; for (int s = 1; s < n; s <<= 1) { for (int i = 0; i < n; i += s << 1) { for (int j = i; j < i + s; j++) { ...
Java
["1 1\n1 2 3\n1 0 1", "2 2\n1 2 1\n0 1 2\n1 2 3", "4 3\n1 2 3\n1 3 7\n0 2 5\n1 0 6\n3 3 2"]
1.5 seconds
["2 4", "4 2 4 6", "198 198 126 126 126 126 198 198"]
NoteIn the first example, the array we formed is $$$(1, 0, 0, 1, 1, 1)$$$, we have two choices to get $$$0$$$ as the XOR and four choices to get $$$1$$$.In the second example, two arrays are $$$(0, 1, 1, 2)$$$ and $$$(1, 2, 2, 3)$$$. There are sixteen $$$(4 \cdot 4)$$$ choices in total, $$$4$$$ of them ($$$1 \oplus 1$$...
Java 8
standard input
[ "math", "fft" ]
379a57ff01d337203bc2fc2cf9f63508
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 10^{5}$$$, $$$1 \leq k \leq 17$$$) — the number of arrays and the binary length of all numbers. The second line contains three integers $$$x$$$, $$$y$$$, $$$z$$$ ($$$0 \leq x,y,z \leq 10^{9}$$$) — the integers you chose. Then $$$n$$$ lines follo...
3,200
Print a single line containing $$$2^{k}$$$ integers. The $$$i$$$-th of them should be the number of ways to choose exactly one integer from each array so that their XOR is equal to $$$t = i-1$$$ modulo $$$998244353$$$.
standard output
PASSED
de0659a72237e9e71c538a8898831f37
train_002.jsonl
1554550500
You have received your birthday gifts — $$$n$$$ triples of integers! The $$$i$$$-th of them is $$$\lbrace a_{i}, b_{i}, c_{i} \rbrace$$$. All numbers are greater than or equal to $$$0$$$, and strictly smaller than $$$2^{k}$$$, where $$$k$$$ is a fixed integer.One day, you felt tired playing with triples. So you came up...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; public class cfGlobal2H { static final int P = 998244353; static final int INV2 = (P + 1) / 2; void fwhtJust(int[] a) { int n = a.length; for (int s = 1; s < n; s <<= 1) { for (int i = 0; i < n; i += s << 1) { for (int...
Java
["1 1\n1 2 3\n1 0 1", "2 2\n1 2 1\n0 1 2\n1 2 3", "4 3\n1 2 3\n1 3 7\n0 2 5\n1 0 6\n3 3 2"]
1.5 seconds
["2 4", "4 2 4 6", "198 198 126 126 126 126 198 198"]
NoteIn the first example, the array we formed is $$$(1, 0, 0, 1, 1, 1)$$$, we have two choices to get $$$0$$$ as the XOR and four choices to get $$$1$$$.In the second example, two arrays are $$$(0, 1, 1, 2)$$$ and $$$(1, 2, 2, 3)$$$. There are sixteen $$$(4 \cdot 4)$$$ choices in total, $$$4$$$ of them ($$$1 \oplus 1$$...
Java 8
standard input
[ "math", "fft" ]
379a57ff01d337203bc2fc2cf9f63508
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 10^{5}$$$, $$$1 \leq k \leq 17$$$) — the number of arrays and the binary length of all numbers. The second line contains three integers $$$x$$$, $$$y$$$, $$$z$$$ ($$$0 \leq x,y,z \leq 10^{9}$$$) — the integers you chose. Then $$$n$$$ lines follo...
3,200
Print a single line containing $$$2^{k}$$$ integers. The $$$i$$$-th of them should be the number of ways to choose exactly one integer from each array so that their XOR is equal to $$$t = i-1$$$ modulo $$$998244353$$$.
standard output
PASSED
6790fdd002ae07ba11cf29c621dbb6e0
train_002.jsonl
1590935700
This is an interactive problem.Ayush devised a new scheme to set the password of his lock. The lock has $$$k$$$ slots where each slot can hold integers from $$$1$$$ to $$$n$$$. The password $$$P$$$ is a sequence of $$$k$$$ integers each in the range $$$[1, n]$$$, $$$i$$$-th element of which goes into the $$$i$$$-th slo...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; public class Round646 { static class Reader { final private int BUFFER_SIZE = 1 << 16; private...
Java
["1\n4 2\n2 1 3\n2 2 4\n\n1\n\n2\n\n3\n\n4\n\nCorrect"]
2 seconds
["? 1 1\n\n? 1 2\n\n? 1 3\n\n? 1 4\n\n! 4 3"]
NoteThe array $$$A$$$ in the example is $$$[1, 2, 3, 4]$$$. The length of the password is $$$2$$$. The first element of the password is the maximum of $$$A[2]$$$, $$$A[4]$$$ (since the first subset contains indices $$$1$$$ and $$$3$$$, we take maximum over remaining indices). The second element of the password is the m...
Java 11
standard input
[ "math", "binary search", "implementation", "interactive" ]
b0bce8524eb69b695edc1394ff86b913
The first line of the input contains a single integer $$$t$$$ $$$(1 \leq t \leq 10)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ $$$(2 \leq n \leq 1000, 1 \leq k \leq n)$$$ — the size of the array and the number of s...
2,100
null
standard output
PASSED
8a658e3a8977fce862be74ba25760706
train_002.jsonl
1590935700
This is an interactive problem.Ayush devised a new scheme to set the password of his lock. The lock has $$$k$$$ slots where each slot can hold integers from $$$1$$$ to $$$n$$$. The password $$$P$$$ is a sequence of $$$k$$$ integers each in the range $$$[1, n]$$$, $$$i$$$-th element of which goes into the $$$i$$$-th slo...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; public class SolutionD extends Thread { static class FastReader { ...
Java
["1\n4 2\n2 1 3\n2 2 4\n\n1\n\n2\n\n3\n\n4\n\nCorrect"]
2 seconds
["? 1 1\n\n? 1 2\n\n? 1 3\n\n? 1 4\n\n! 4 3"]
NoteThe array $$$A$$$ in the example is $$$[1, 2, 3, 4]$$$. The length of the password is $$$2$$$. The first element of the password is the maximum of $$$A[2]$$$, $$$A[4]$$$ (since the first subset contains indices $$$1$$$ and $$$3$$$, we take maximum over remaining indices). The second element of the password is the m...
Java 11
standard input
[ "math", "binary search", "implementation", "interactive" ]
b0bce8524eb69b695edc1394ff86b913
The first line of the input contains a single integer $$$t$$$ $$$(1 \leq t \leq 10)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ $$$(2 \leq n \leq 1000, 1 \leq k \leq n)$$$ — the size of the array and the number of s...
2,100
null
standard output
PASSED
a2bc4fe2ec2325b312bafe8cec1e782a
train_002.jsonl
1590935700
This is an interactive problem.Ayush devised a new scheme to set the password of his lock. The lock has $$$k$$$ slots where each slot can hold integers from $$$1$$$ to $$$n$$$. The password $$$P$$$ is a sequence of $$$k$$$ integers each in the range $$$[1, n]$$$, $$$i$$$-th element of which goes into the $$$i$$$-th slo...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; import java.math.*; public class D { public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb; int t = Integer.parseInt(bf.readLine()); for (i...
Java
["1\n4 2\n2 1 3\n2 2 4\n\n1\n\n2\n\n3\n\n4\n\nCorrect"]
2 seconds
["? 1 1\n\n? 1 2\n\n? 1 3\n\n? 1 4\n\n! 4 3"]
NoteThe array $$$A$$$ in the example is $$$[1, 2, 3, 4]$$$. The length of the password is $$$2$$$. The first element of the password is the maximum of $$$A[2]$$$, $$$A[4]$$$ (since the first subset contains indices $$$1$$$ and $$$3$$$, we take maximum over remaining indices). The second element of the password is the m...
Java 11
standard input
[ "math", "binary search", "implementation", "interactive" ]
b0bce8524eb69b695edc1394ff86b913
The first line of the input contains a single integer $$$t$$$ $$$(1 \leq t \leq 10)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ $$$(2 \leq n \leq 1000, 1 \leq k \leq n)$$$ — the size of the array and the number of s...
2,100
null
standard output