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
46d1760a3b0b6c03dc3e8d591687f301
train_000.jsonl
1526308500
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. ...
256 megabytes
import java.io.*; import java.util.Arrays; public class Main { static int n, l; public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); n = Integer.parseInt(br.readLine()); int[] beauty = new int[3]; for(int i = 0; i...
Java
["3\nKuroo\nShiro\nKatie", "7\ntreasurehunt\nthreefriends\nhiCodeforces", "1\nabcabc\ncbabac\nababca", "15\nfoPaErcvJ\nmZaxowpbt\nmkuOlaHRE"]
1 second
["Kuro", "Shiro", "Katie", "Draw"]
NoteIn the first example, after $$$3$$$ turns, Kuro can change his ribbon into ooooo, which has the beauty of $$$5$$$, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most $$$4$$$, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon...
Java 8
standard input
[ "greedy" ]
9b277feec7952947357b133a152fd599
The first line contains an integer $$$n$$$ ($$$0 \leq n \leq 10^{9}$$$) — the number of turns. Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than $$$10^{5}$$$ uppercase and lowercase Latin letters and is not empty. It is guaranteed tha...
1,800
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
standard output
PASSED
f7a699408438bd15e0bad01f92425adc
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static int n, a, b; static ArrayList<Integer>[] graph; static long[] da, db; public s...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
ff514109d8f79ff14228974438c7db5d
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
/*Author: Satyajeet Singh, Delhi Technological University*/ import java.io.*; import java.util.*; import java.text.*; import java.lang.*; public class Main { /*********************************************Constants******************************************/ static PrintWriter out=new PrintWriter(new OutputStreamWr...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
cf2c97f81f9ebb9360044c4600a84162
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
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.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.io.BufferedReader; impo...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
88c46dc802e1e89344d640815f2df4e0
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
265530eb1be592897e012529928c179d
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.util.*; import java.io.*; //import java.text.*; public class Main{ final long MOD = (long)1e9+7, IINF = (long)1e19; final int MAX = (int)1e6+10, MX = (int)1e7+1, INF = (int)1e9; // DecimalFormat df = new DecimalFormat("0.00000000"); // final double EPS = 1e-8; FastReader in; PrintWrit...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
37464e494a163828ff4786dc4c3c9583
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.*; import java.math.*; import java.nio.file.attribute.AclEntry.Builder; import java.security.KeyStore.Entry; import java.util.*; public class CODEFORCES { private InputStream is; private PrintWriter out; int time = 0, dp[][], DP[], start[], end[], dist[], red[], black[], MOD = (int)(1e9+7), arr[]; ...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
6ab42f99095250bf576146ce4700b089
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.util.PriorityQueue; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class bowwow { private static ArrayList<Integer> arr[]; private static int n; private static int x...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
c853b60c7fd6d67d8797943af8557138
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
//package educational.round22; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Queue; public class C { InputStream is; PrintWriter o...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
a2b29e50c17000f905fad9d17a5f6e40
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class codeforces implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; ...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
ed54999ddb60c9a4174dd3df09c5df22
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class EducationalRound22C { static int ans = -1; static int x; static List<ArrayList<Integer>> neighbors; static int[] maxDepths; public static void main(String[] args) throws Exception { int n = r...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
ca927e52fff4e3260257b1e99b7fcb01
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class TheTagGame{ public static class FastReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilter filter; public Fas...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
0f458bbc582ad1df0440856f42f00836
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.util.concurrent.*; public final class tag_game { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); static Random rn...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
2eb62b6efee89a0353932a9d36eefb34
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.*; import java.util.*; public class Edu22_C { static ArrayList<Integer>[] adjList; public static void main(String[] args) throws IOException { BufferedInputStream bis = new BufferedInputStream(System.in); BufferedReader br = new BufferedReader(new InputStreamReader(bis)); PrintWriter out = new P...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
84b34b57d74758878b83a3f6a6319495
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.max; /** * Created by Katushka on 11.03.2020. */ public class C { static int[] readArray(int size, InputReader in) { int[] a = new int[size]; for (int i = 0; i < size; i++) { a[i] = in.nextInt(); } re...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
751be8795f4cda585341e3b1b61e0552
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.util.*; import java.io.*; public class C813 { public static void main(String args[])throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer str = new StringTokenizer(br.readLine()); int n = Integer.p...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
5b7c0e71d32ef0a416ee6ae0330c5e01
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class C813_DFS { public static void main(String args[]) throws Exception { BufferedReader br = new BufferedReader(new InputStr...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
b9c96d6409d3ca382613fdef476ff454
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main{ /* * use Integer for sorting * avoid object comparison * NEVER APPEND A STRING -> APPEND char by char * Always use TreeSet instead of HashSet * */ public static class FastReader { BufferedReader br; StringTokeniz...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
cf7767e508220e2bb5c31c988de69506
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
// editorial approach import java.util.*; import java.io.*; public class Main { static final int N = (int)4e5; static int n, B, tot, j, k; static int[] g, pt, nt, d[]; static void link(int x, int y) { pt[++tot] = y; nt[tot] = g[x]; g[x] = tot; pt[++tot] = x; nt[tot] = g[y]; g[y] = tot; } static void df...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
35be9a3aa5fcd3c720f7180a738a8fa7
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.*; import java.util.*; public class TheTagGame { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); ...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
d9cb107bbdcc7de836888a517be77f03
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.*; import java.util.*; public class TheTagGame { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); ...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
c166cc8eed64f6a9637a286d55e3f635
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); new Main().run(in, out); out.close(); } int N; int B; Li...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
aa6c1e37222cf524936e4efd365c4cec
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
/* ID: mchensd LANG: JAVA PROG: TheTagGame */ /** * * @author Michael */ import java.util.*; import java.io.*; public class TheTagGame { static int m; static int[] maxPath; static int[] abPath; static int pathInd, finalPathInd; static boolean found = false; public static class Tree { ...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
e22d51f84705b17f3a49576405f9fe9a
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class C { static int N...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
4a2d9477a2fed58f0d1a133c6d7972c3
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.util.*; import javax.swing.Painter; import java.io.*; public class C { FastScanner in; PrintWriter out; boolean systemIO = true; public static class Pair implements Comparable<Pair> { int x; int y; public Pair(int x, int y) { super(); this.x = x; this.y = y; } @Override public ...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
b7666fedb9acbb21c753d0b13bba5605
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.util.Scanner; import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class M { /*int x,y; public TestClass(int x,int y) { this.x=x; this.y=y; }*/ public static void main(String args[]) throws Exception { //Scanner scan=new Scanner(S...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
9a4b3612f7442105880ca354a066711b
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.util.Scanner; import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class TestClass //implements Runnable { /*int x,y; public TestClass(int x,int y) { this.x=x; this.y=y; }*/ public static void main(String args[]) throws Exception {/...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
335826b5d64170f0a4f359d9cf89a9fd
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.*; import java.util.*; public class Main { private static Scanner sc; private static Printer pr; static long aLong=(long )1e9+7; static long Mod=998244353; static TreeSet<Integer>[]list; static int []distanceX; static int []distanceRoot; static boolean[]visRoot; stat...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
ddd5551853d6a4a9bc60d62b854c9ef2
train_000.jsonl
1496675100
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. ...
256 megabytes
import java.io.*; import java.util.*; public class Main { private static Scanner sc; private static Printer pr; static long aLong=(long )1e9+7; static long Mod=998244353; static TreeSet<Integer>[]list; static int []distanceX; static int []distanceRoot; private static void solve() throw...
Java
["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5"]
1 second
["4", "6"]
NoteIn the first example the tree looks like this: The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:B: stay at vertex 3A: go to vertex 2B: stay at vertex 3A: go to vertex 3In the second exam...
Java 8
standard input
[ "dfs and similar", "graphs" ]
0cb9a20ca0a056b86885c5bcd031c13f
The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n). Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.
1,700
Print the total number of moves Alice and Bob will make.
standard output
PASSED
a28d88de4e1263bfd98fe7cceed624e7
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; public class CF177C { static List<Set<Integer>> groups = new ArrayList<>(); static List<Boolean> g...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
ea7e611cc2901d7b20cecf51059da91a
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class cf177c { public static void main(String[] args) { ...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
28bd88b3225065098c885dfc5a372d60
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class Solution { //<editor-fold desc="input parse" defaultstate="collapsed"> private static StringTokenizer st; private static BufferedReader reade...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
40367d331b522a32a45a4a0cedc9b641
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.util.LinkedList; import java.util.Scanner; /** * Created with IntelliJ IDEA. * Author : Dylan * Date : 2013-08-10 * Time : 14:40 * Project : Party 3 */ public class Main { static LinkedList<Integer>[] graph; static int[] root; static boolean[] visited; static int n, curren...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
03e2b7ca6379425e50842e83909e41ac
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.util.LinkedList; import java.util.Scanner; /** * Created with IntelliJ IDEA. * Author : Dylan * Date : 2013-08-10 * Time : 14:40 * Project : Party 3 */ public class Main { static LinkedList<Integer>[] graph; static int[] root; static boolean[] visited; static int n, curren...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
1b1f5d7c1267a160f5e9df5519bdb54f
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable { int N, F, E; ArrayList<Integer>[] graph; boolean[][] enemy; boolean[] was; List<Integer> q; public void solve() throws IOException { N = nextInt(); graph = new ArrayLi...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
a79090a3070f46f9166e8d9da9a6ffae
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; public class AbbyCupC1Party { public static void main(String args[] ) throws Exception { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); ...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
6ec53af988e80ff1470c22c6a827a93d
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.io.*; import java.util.*; public class Task { public static void main(String[] args) throws Exception { new Task().solve(); } int n; boolean f[][]; boolean h[][]; boolean d[]; ArrayList <Integer> list= new ArrayList <Integer> (); void dfs(int v) { d[v] = true; // System.out.println(v); l...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
92b66d42123aba942e803a838afc8dc2
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; //4/22/12 1:43 AM //by Abrackadabra public class C1 { public static void main(String[] args) throws IOException { if (args.length > 0 && args[0].equals("Abra")) debugMode = true; new C1().run(); /*new Thread(null, new Runnable() { ...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
557775ee39de77fd24f4f1053624a5a3
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.Comparator; import java.io.OutputStream; import java.io.PrintWriter; import java.util.AbstractList; import java.io.Writer; import java.util.Collection; import java.util.List; import java.io.IOException; import java.util.InputMismatchExce...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
a7ffc39c24015fe48ebd14de37971df4
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.util.Scanner; /** * @Author Mikhail Linkov * Date: 21.04.12 */ public class ProblemC { private static int [][] matrix; private static int [] comp; private static int count = 0; private static int compNum; private static int flag; private static void dfs(int vertex) { cou...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
dd7b0b0ec773cd0fdcef332924af9ab0
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class CodeI { static class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Stri...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
83025466e715a4642766636ec47081b3
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.io.*; import java.security.SecureRandom; import java.util.*; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { int n, k, m; ArrayList<ArrayList<Integer>> friend = new ArrayList<>(); ArrayList<ArrayList<Integer>> enemy = new...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
7cbf741ec9b58adec3f45a08fccbc1bf
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static BufferedReader in; public static PrintWriter out; public static void main(String[] a...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
d8153caa1a7d0c74345d4c1633a53478
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; import java.util.Set; public class C { static InputStreamReader in = new InputStreamReader(System.in); sta...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
dfb43c731f69b41af8b85cc285301910
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
/* ID: govind.3, GhpS, govindpatel LANG: JAVA TASK: Main */ import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { /** * Min segment Tree takes the minimum number at the root */ class MinSegmentTree { /** * root: Tree root, balance: input array...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
c854d1d4951845f0c134c625cfe2e9ac
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable { boolean[] visited; public void solve() throws IOException { int n = nextInt(); int m = nextInt(); int[] p = new int[n]; for (int i = 0; i < n; i++) { p[i] = i; } for (int...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
cde2cf8025a6fe7d8662e489f32c225f
train_000.jsonl
1335016800
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
256 megabytes
/* ID: govind.3, GhpS, govindpatel LANG: JAVA TASK: Main */ import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { /** * Min segment Tree takes the minimum number at the root */ class MinSegmentTree { /** * root: Tree root, balance: input array...
Java
["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9"]
2 seconds
["3"]
NoteLet's have a look at the example. Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its memb...
Java 7
standard input
[ "dsu", "dfs and similar", "brute force", "graphs" ]
e1ebaf64b129edb8089f9e2f89a0e1e1
The first line of input contains an integer n — the number of the Beaver's acquaintances. The second line contains an integer k — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi — indices of people who form the i-th pair of friends. The next line contains an integer m —...
1,500
Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.
standard output
PASSED
ad7eeffa7fa2c60f378872b8e77d9914
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.util.Scanner; public class C25 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[][] dist = new int[n][n]; long sum = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { dist[i][j] = in.nextInt(); sum += dist[i][j]; ...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
e58afba1973a9e640e0e24ae3152817d
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] arg) { FastScanner scan = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); ...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
bedfbf3d60dff6659ad68a5d83949f7a
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.util.*; public class RoadsInBerland { public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n=sc.nextInt(); long [][] graph= new long[n][n]; for(int i=0 ; i<n ; i++){ for(int j=0 ; j<n ; j++){ graph[i][j]=sc.nextLong...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
86c3cfde8daac75077f0ce38fd7d403d
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.io.*; import java.util.*; public class RoadsinBerlandDiv2 { private static int V; private static int newE; private static long[][] graph = new long[301][301] ; public static void main(String[] args){ PrintWriter pw = new PrintWriter(System.out, true); Scanner sc = new Scanne...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
8b0e05c562f3e64528036cb70d9ded9c
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class RoadsInBerland_25 { public static void main(String[] args) throws IOException { // ---------------------------------------------------- start(); // ---------------------------------------------------- int n = ne...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
12eb014a3b989dcf21ce4e5f3eeb4521
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class RoadsInBerland_25 { public static void main(String[] args) throws IOException { // ---------------------------------------------------- start(); // ---------------------------------------------------- int n = ne...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
4062739184887d80049a6136ae9d14ce
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
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; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Stack; /*...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
b202b7f193741b77eb3e6cd0d09df4e6
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.util.Scanner; public class P25C { public P25C() { Scanner sc = new Scanner (System.in); int n = sc.nextInt(); long sum = 0; int [][]distances = new int [n+1][n+1]; for (int i = 1; i <= n; i++){ for (int j = 1; j <= n;j++){ distances[i...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
4dab4e3ed1f675547157e9d63b49dfa6
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.util.Arrays; import java.util.Scanner; /** * Created with IntelliJ IDEA. * Author : Dylan * Date : 2013-08-10 * Time : 12:46 * Project : Roads in Berland */ public class Main { static int[][] graph; static int n, k; public static void main(String[] args) { Scanner in ...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
be4166e8d1c6f84659250b8ec050db23
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.util.Arrays; import java.util.Scanner; /** * Created with IntelliJ IDEA. * Author : Dylan * Date : 2013-08-10 * Time : 12:46 * Project : Roads in Berland */ public class Main { static int[][] graph; static int n, k; public static void main(String[] args) { Scanner in ...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
e9e0619929094f9d11598553249f523c
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.util.Scanner; public class c25 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int INF = Integer.MAX_VALUE / 2; int n = in.nextInt(); int[][] adjMat = new int[n + 1][n + 1]; for (int i = 1; i <= n; i++) { for (int j = ...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
a467214d6a6564078ae870cf4974c06e
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable { public void solve() throws IOException { int N = nextInt(); long sum = 0; int[][] grid = new int[N][N]; for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) ...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
b54041c63c0b62b88e20be76faa60586
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class R25qCRoadsInBerland { public static void main(String args[] ) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWri...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
f2b044de9c466af8ab52d2db694bbb61
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.util.Scanner; public class Roads_in_Berland { class Road { public int i, j, c; public Road(int i1, int j1, int c1) { i = i1; j = j1; c = c1; } } public int n, k; public long[][] dist; public Road[] newRoads; void read(...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
aaaa1c46c508887c7e438e8d9ccf439f
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; 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 * @author Zyf...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
1390aea27bb73632f61b90467b85e28d
train_000.jsonl
1280761200
There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance betw...
256 megabytes
import java.io.*; import java.util.*; public class try23 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner k=new Scanner(System.in); int n=k.nextInt(); int[][]dist0=new int[n][n]; for (int i = 0; i < dist...
Java
["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1"]
2 seconds
["3", "17 12"]
null
Java 7
standard input
[ "shortest paths", "graphs" ]
5dbf91f756fecb004c836a628eb23578
The first line contains integer n (2 ≤ n ≤ 300) — amount of cities in Berland. Then there follow n lines with n integer numbers each — the matrix of shortest distances. j-th integer in the i-th row — di, j, the shortest distance between cities i and j. It is guaranteed that di, i = 0, di, j = dj, i, and a given matrix ...
1,900
Output k space-separated integers qi (1 ≤ i ≤ k). qi should be equal to the sum of shortest distances between all pairs of cities after the construction of roads with indexes from 1 to i. Roads are numbered from 1 in the input order. Each pair of cities should be taken into account in the sum exactly once, i. e. we cou...
standard output
PASSED
e5344dfe8da3e8ae23b845b607452559
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution is at the top * @author Rubanenko */ public class M...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
71d04a677873890110624ea7c1b10c94
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; public class MainClass { public static void main(String[] args)throws IOException { Reader in = new Reader(); int n = in.nextInt(); int[] A = new int[n]; for (int i=0;i<n;i++) A[i] = in.nextI...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
3af8386cd3e11bb1a3d6b2cbe49d4f8b
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Bit...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
1a3a80fd17e6bd26da361fb5d8f9655b
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
/*Author: Satyajeet Singh, Delhi Technological University*/ import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.*; public class Main{ /*********************************************Constants******************************************/ static PrintWrite...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
d61893cccd907fe910617240f95eb404
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
/*Author: Satyajeet Singh, Delhi Technological University*/ import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.*; public class Main{ /*********************************************Constants******************************************/ static PrintWrite...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
52677f8409d4318c63d908d85f8ad3bb
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
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 static ...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
b38de0f145eee100e5c3d5a06155c4bb
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class D257 { static final long MOD = (long)(1e9+7); static long[] fs; static long[][] memo; public static void main(String[] args)...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
656c058f7d893ecb6635495538e57b3e
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.math.BigInteger; import java.util.*; import java.io.*; import java.text.*; public class Main{ //SOLUTION BEGIN //Into the Hardware Mode void pre() throws Exception{} void solve(int TC) throws Exception{ int n = ni(), B = 20; long[] a = new long[1<<B]; long MOD = (long...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
5b537deb50671afcaa7605b9a71b6aa3
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.util.Scanner; /** * Created by David Lee on 2017/6/22. */ public class Main { static int P = 1000000007, N = 1<<20 + 5, k = 1<<20; static int a[] = new int [N]; static private int ksm(int a, int b) { int c = 1, d = a; while (b > 0) { if((b & 1) != 0) ...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
ed30e843c6d29b65a986f8112904a622
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Round257Div1D { public static long mod = (long)1e9+7; public static void solve() { int n = s.nextInt(); int m = 20; int size = 1<...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
88b9f1d0be0c8ff1f446f894d115db12
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.io.*; import java.util.*; public class D { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; static final int LOG = 20; static final int N = 1 << LOG; static final int MOD = 1_000_000_007; void solve() throws IOException { int n = nextInt(); int[] a = new int[N]; for (in...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
226ccbfd8d663c9f8777b168c5096f96
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
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; /** * @author khokharnikunj8 */ public class Main { public static void main(String[] args) { ...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
a6e8c3854be5f49dae0c47691b9e2bac
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; public class JzzuandNumbers{ int n; int[] arr; int[][] dp; int[] READER; void read()throws Exception{ READER = new int[1000005]; BufferedReader bi = new BufferedReader(new InputStreamReader(System.in)); String line; int ind=0; while ((line = b...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 8
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
44316496060cefb8ca322d662b0cadda
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 6
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
7c1a2aff3cb79a5f2ad36795cce981f3
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.io.*; import static java.lang.Math.pow; import java.math.BigInteger.*; import static java.math.BigInteger.*; import java.util.*; import static java.util.Arrays.fill; import static java.util.Arrays.fill; //<editor-fold defaultstate="collapsed" desc="Imports"> //</editor-fold> // https://netbeans.org/kb/73/j...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 6
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
4b89ae7daa46dee60392746cf9479f44
train_000.jsonl
1405774800
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
256 megabytes
import java.util.Scanner; public class Main { private static final int mod = (int)1e9+7; public static void main(String[] args) { // TODO Auto-generated method stub try{ Scanner sc = new Scanner(System.in); String input1 = sc.nextLine(); String input2 = sc.nextLine();...
Java
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
2 seconds
["0", "10", "53"]
null
Java 6
standard input
[ "dp", "combinatorics", "bitmasks" ]
0c5bc07dec8d8e0201695ad3edc05877
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
2,400
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
standard output
PASSED
4d1dd17a56ca79c7f79a42843b3ac2e5
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
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 j = 0; j < t; j++) { int n = sc.nextInt(); int aaa = 0; int numOdds = 0; int numEvens = 0; for (int i = 0; i < n; i++) { aaa = sc.next...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
7e01e2aad5530723c3ec168fa10ef13a
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); for (int i = 0; i < n; i++) { int odd = 0 , ev = 0 ,sum = 0 ; int p = input.nextInt(); for (int j = 0; j <p; j++) { int x = inpu...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
34adc87eeb0d6a7ddfae02171b7248a1
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args)throws IOException{ Scanner sc = new Scanner (System.in); int cont = sc.nextInt(); while(cont > 0){ int tam = sc.nextInt(); int[] arr = new int[tam]; ...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
add1941952bcc500db965053b872a123
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args)throws IOException{ Scanner sc = new Scanner (System.in); int cont = sc.nextInt(); while(cont > 0){ int tam = sc.nextInt(); int[] arr = new int[tam]; ...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
62fe949f2495ed054bfc73e989b7a5a6
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
/** * @author : Kshitij */ import java.io.*; import java.util.InputMismatchException; public class Main { public static void main(String[] xps){ InputReader in = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); StringBuilder stringBuilder = new StringBuilder();...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
9151a086a4ea5ca80399a50eab4bd472
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.*; public class Main{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int testCase = scan.nextInt(); for(int i = 0; i < testCase; i++){ int odd = 0; int even = 0; int num = scan.nextInt...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
150fc78593c194982351c53a8f6f5530
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.Scanner; public class Array_Odd_Sum { public static void main(String[] args) { Scanner in = new Scanner(System.in); int test = in.nextInt(); for (int i = 0; i < test; i++) { int size = in.nextInt(); int sum = 0; int se = 0; in...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
bd7900fb58c5d987ef83533a4c3a7e02
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.Scanner; import java.util.Arrays; import java.lang.*; import java.io.*; import java.util.*; import java.util.HashSet; import java.util.Set; import java.util.stream.*; import java.util.function.Function; public class ArrayWithOddSum { public static void main(String[] args)throws IOException { Scanne...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
afc4825d4e308900658af01ef5365a85
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.Scanner; /** * * @author Tonmoy */ public class Array_with_Odd_Sum_1296A { public static void main(String[] args) { Scanner In=new Scanner(System.in); int t=In.nextInt(); for (int i = 0; i < t; i++) { int n=In.nextInt(); int sum=0; i...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
14e362b4a975b67d1236f1848ad367e0
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
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 { static int a =0; static int b =0; public static void main (String[] args) throws java.lang.Exception { ...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
673e38d05d24b4ef670360539c85aa1b
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
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 { static int a =0; static int b =0; public static void main (String[] args) throws java.lang.Exception { ...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
189c29f5003b5de06dc3baff038c3bbc
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.Scanner; public class qqq { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int testcase = scan.nextInt(); int num; for (int i = 0; i < testcase; i++) { num = scan.nextInt(); int n = 0; boolean odd = false; boolean even = false; for (int j = 0...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
91a433e2bca9be011b97919bebeba617
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; public class code_main{ public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
f49680106840eb4039590b2cdf355b59
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.io.*; import java.util.*; public class A { static FastReader sc=new FastReader(); public static void main(String[] args) { int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int a[]=readArray(n); int c=0; for(int e:a) { if(e%2==1) c++; } if(c%2==1 || (c%2==0 && c!=n && ...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
310a8d39a77a16e293f24604f49f5b70
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.*; public class Code1{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int t = scan.nextInt(); for(int i=0;i<t;i++){ int n = scan.nextInt(); int[] arr = new int[n]; int sum =0; int even =0; ...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
3dbf26b18e1ccf808edbdf7828fdea60
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.*; import java.lang.*; 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 arr[] = new int[n]; int sum=0; boolean even = ...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
5940968eb76c5180a30a33417aeff9ab
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.*; import java.io.*; public class ASoln { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while(st == null || !st.hasMoreElements()) { try { st= new St...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
7c54c3c366cbe44acbd4b0c991aa1427
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Solution { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); //int cnt=0,...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
c95d1b544c6d6d6a0c9763c3a8dd1546
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class codeforces { 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 oddCount = 0; ...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
7576b894c3bc5d5a355b9166893f7884
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.*; public class MyClass { public static void main(String args[]){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i=0;i<t;i++){ int size = sc.nextInt(); int even=0,odd=0; for(int j=0;j<size;j++){ ...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output
PASSED
f48fd69b832b04e05ab8e2e4988295cd
train_000.jsonl
1580826900
You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th...
256 megabytes
import java.util.*; public class Main{ public static void main(String args[]){ Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int j = 0; j < t; j++){ int n = in.nextInt(); int odd = 0; int even = 0; for(int i = 0; i < n; i++){ ...
Java
["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"]
1 second
["YES\nNO\nYES\nNO\nNO"]
null
Java 11
standard input
[ "math" ]
2e8f7f611ba8d417fb7d12fda22c908b
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) — the number of elements in $$$a$$$. The second line of the test case contains ...
800
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
standard output