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
45544540c0cbf379513ef785aa74b3b1
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { static BufferedReader in; static PrintWriter out; public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
99b72fc830c2a14478f308d4edf0e7dd
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.io.PrintStream; import java.util.Scanner; public class B { private static PrintStream out = System.out; public static void main(String[] args) { // read input Scanner in = new Scanner(System.in); int n = in.nextInt(); char[] s = in.next().toCharArray(); char[] t = in.next().toCharArray(); ...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
d2dc8b4a9fc117e99315d2a73b6fe820
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.io.*; import java.io.PrintWriter; import java.util.*; import java.io.InputStream; import java.io.DataInputStream; public class cookoff{ public static void main(String[] args) throws IOException {InputStream inputStream = System.in; OutputStream outputStream = System.out; FastReade...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
8f1a4b20bf58c9d3fba5d3880adba0ea
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
//package codeforces.cfr296div2; import java.util.Scanner; /** * Created by bistrashkin on 3/17/15. */ public class B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); String s = in.nextLine(); String t = in.nextL...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
dc98a3de67a9ae9f013fa0badf639316
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Main { private static void solve() { int length = nextInt(); String a = next(); String b = next(); int [] a...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
4f8ec04c55d7cbdaadd3646fef185324
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.StringTokenizer; public class Main { static FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in))); static PrintWriter...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
47e3b0c7c39eb1990307971ab93948ce
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; public class CF527B { /* * ab * ba * * last seen at idx 0. last seen b at idx 1. * <a b> at idx 0. <b a> at idx 1. */ static class Hemming { String s; St...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
287c027f10b571031fe667118406589c
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.io.*; public class C296_2 { public static void main(String []args) throws IOException { new Solution().solve(); } } class Solution { FastReader fr = new FastReader(); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); public void solve() throws IOExcep...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
05b762fccef2a785b0409ace4182d31b
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; import java.util.regex.*; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); br = new...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
7a15a29c4ee7ea533c389cee50e62027
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.io.PrintWriter; import java.util.HashMap; import java.util.Scanner; /** * Created by Hedin on 17-Mar-15. */ public class ProblemB { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); sc.nextInt(); ...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
11d6952ff9548c77e89cfe2f0299204d
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; public class TaskB { public FasterScanner mFScanner; public PrintWriter mOut; public int map[][]; public int rMap[][]; public TaskB() { mFScanner = new FasterScanner(); mOut = new Pri...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
28b0694ec5e12754d3e2e2ef737997eb
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.StringTokenizer; import java.io.InputSt...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
b15c91c107d830b3e5a32bf5c2a5584c
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.util.Arrays; 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 */ public cla...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
b589f8c3ce21adf61e1b534e2185c3f8
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author HafeezulRahman */ import java.io.*; import java.util.*; public class B296 { public static void main(String[] ar...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
1160bc74154227d96aa006306943f49b
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(reader.readLine()); char[] s1 = reader.readLine().toCharArray(); char[] s2 = re...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
3720983073ddc57b2e0ae078d1bda292
train_000.jsonl
1426610700
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In...
256 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.Scanner; import javax.sound.midi.SysexMessage; public class B296 { /** * @param args */ public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int strLength=scanner.nextInt(); Str...
Java
["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle"]
2 seconds
["1\n4 6", "1\n-1 -1", "2\n1 2", "2\n4 1"]
NoteIn the second test it is acceptable to print i = 2, j = 3.
Java 7
standard input
[ "greedy" ]
2fa543c8b8f9dc500c36cf719800a6b0
The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.
1,500
In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or p...
standard output
PASSED
64670edefe95c3e5802d9586b3a92587
train_000.jsonl
1424190900
Drazil created a following problem about putting 1 × 2 tiles into an n × m grid:"There is a grid with some cells that are empty and some cells that are occupied. You should use 1 × 2 tiles to cover all empty cells and no two tiles should cover each other. And you should print a solution about how to do it."But Drazil d...
256 megabytes
import java.io.*; import java.util.*; public class Main { final int dx[]={-1,0,1,0}; final int dy[]={0,-1,0,1}; private void solve()throws IOException { int n=nextInt(); int m=nextInt(); char grid[][]=new char[n+1][m+1]; int degree[][]=new int[n+1][m+1]; for(int i=1;i<=n;i++) { String s=nextLine(); ...
Java
["3 3\n...\n.*.\n...", "4 4\n..**\n*...\n*.**\n....", "2 4\n*..*\n....", "1 1\n.", "1 1\n*"]
2 seconds
["Not unique", "&lt;&gt;**\n*^&lt;&gt;\n*v**\n&lt;&gt;&lt;&gt;", "*&lt;&gt;*\n&lt;&gt;&lt;&gt;", "Not unique", "*"]
NoteIn the first case, there are indeed two solutions:&lt;&gt;^^*vv&lt;&gt;and^&lt;&gt;v*^&lt;&gt;vso the answer is "Not unique".
Java 11
standard input
[ "constructive algorithms", "greedy" ]
9465c37b6f948da14e71cc96ac24bb2e
The first line contains two integers n and m (1 ≤ n, m ≤ 2000). The following n lines describe the grid rows. Character '.' denotes an empty cell, and the character '*' denotes a cell that is occupied.
2,000
If there is no solution or the solution is not unique, you should print the string "Not unique". Otherwise you should print how to cover all empty cells with 1 × 2 tiles. Use characters "&lt;&gt;" to denote horizontal tiles and characters "^v" to denote vertical tiles. Refer to the sample test for the output format exa...
standard output
PASSED
582aab8f806e11eeb753b5375573d1ce
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.util.*; public class Taxi { public static void main(String args[]){ Scanner sc=new Scanner (System.in); Integer [] s; int sum=0; s =new Integer [4]; for(int i=0;i<4;i++){ s[i]=0; } int n=sc.nextInt(); for(int i=0;i<n;i++){ ...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
e606a4c73ecda9ab19fc7b597a3efb8d
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.io.IOException; import java.util.Scanner; public class Taxi { public static void main(String[] args) throws IOException { Scanner scn = new Scanner(System.in); int groups=scn.nextInt(),a=0,b=0,c=0,d=0; for(int i=0;i<=groups-1;i++){int x = scn.nextInt();switch(x){ case 4:a++;break;case 3...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
a4bf49af3e169d97746d80370367b7f0
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class _158B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); Integer[] groups = new Integer[n]; for (int i = 0; i < n; i++) groups[i...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
8e95014ad03356bcf10ed33d13f89900
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input=new Scanner(System.in); int n=input.nextInt(); int[] s=new int[n]; int cnt1=0,cnt2=0,cnt3=0,cnt=0; for(i...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
2381eb7a600c49f179c0d3d50165c842
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.util.*; public class JavaApplication1 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int ans = 0; int f[] = new int[5]; for (int i = 0; i < n; i++) { f[in.nextInt()]++; } ans += ...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
cb4554e10b5d82eebbd8fb7bb3472631
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.util.*; public class Problem2 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner (System.in); int n = sc.nextInt(); int [] a = new int [n]; for (int i = 0; i<n; i++){ a[i] = sc.nextInt(); } Arrays.sort(a); int result = 0;...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
b427cf2dbe88bdf2b7278c94521213c9
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
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
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
fd87fff8d6468c523d43eac255132972
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.util.*; public class Taxi { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input=new Scanner(System.in); int n=input.nextInt(); if(n>=1&&n<=100000){ int []s=new int[n]; int c=0; for(int i=0;i<s.length;i++){ s[i]=input.next...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
668281157edab31c4c24afd8c6f250c5
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.io.PrintWriter; import java.util.ArrayList; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); //all elements counts increment as input comes in ...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
d2b1cad66aafbb79fc6de30c8e2373a7
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.util.Arrays; public class Program { public static void main(String[] args) throws IOException { StreamTokenizer st = new StreamTokenizer(new BufferedReader( ...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
d852802553e6116b377d9425230ff0cc
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Taxi158B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] groups = new int[4]; Arrays.fill(groups, 0); for (int i = 0; i < n; i++) { int s = in.nextInt(); groups[s - 1]++; } i...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
f8b97b027f37197436fb814308e41007
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import static java.lang.System.out; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner kb = new Scanner(System.in); int t = kb.nextInt(); int[] k = new int[t]; int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0; for(int i = 0; i < k.length; i++){ k[i] = kb.nextInt(); ...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
b790ff09f1de73baab143c1401de25c4
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.util.Scanner; import java.math.*; import java.util.*; public class JavaAcm { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int[] number = new int[10]; int i , n , ans = 0 , t; n = scan.nextInt(); for(i = 0 ;i < n;i ++) { int input; input = scan.n...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
774e7ed9f5afe7e9628ce9d5a5cd8a3d
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Taxi { public static int t =0 ; public static BufferedReader in; public static StringTokenizer st; public static String nextToken() throws IOExce...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
d094bbcf3e7f03ffc22c31fc6b0a0cb9
train_000.jsonl
1330804800
After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum nu...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); // データ件数 int[] seq = n...
Java
["5\n1 2 4 3 3", "8\n2 3 4 4 2 1 3 1"]
3 seconds
["4", "5"]
NoteIn the first test we can sort the children into four cars like this: the third group (consisting of four children), the fourth group (consisting of three children), the fifth group (consisting of three children), the first and the second group (consisting of one and two children, correspondingly). There are oth...
Java 6
standard input
[ "implementation", "*special", "greedy" ]
371100da1b044ad500ac4e1c09fa8dcb
The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.
1,100
Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.
standard output
PASSED
dc0605efb790e400ae778323f0beab40
train_000.jsonl
1537707900
You are given a tuple generator $$$f^{(k)} = (f_1^{(k)}, f_2^{(k)}, \dots, f_n^{(k)})$$$, where $$$f_i^{(k)} = (a_i \cdot f_i^{(k - 1)} + b_i) \bmod p_i$$$ and $$$f^{(0)} = (x_1, x_2, \dots, x_n)$$$. Here $$$x \bmod y$$$ denotes the remainder of $$$x$$$ when divided by $$$y$$$. All $$$p_i$$$ are primes.One can see that...
512 megabytes
import java.util.Arrays; import java.util.Scanner; // 2*7*11 7*13 11*13 public class d { static int N = 2000001; static final long MOD = (int) (1e9+7); public static void main(String[] args) { int[] pf = new int[N]; for(int i=2;i<N;i++) { if(pf[i] != 0) continue; for(int j=i;j<N;j+=i) pf[j] = i; ...
Java
["4\n2 3 5 7", "3\n5 3 3"]
2 seconds
["210", "30"]
NoteIn the first example we can choose next parameters: $$$a = [1, 1, 1, 1]$$$, $$$b = [1, 1, 1, 1]$$$, $$$x = [0, 0, 0, 0]$$$, then $$$f_i^{(k)} = k \bmod p_i$$$.In the second example we can choose next parameters: $$$a = [1, 1, 2]$$$, $$$b = [1, 1, 0]$$$, $$$x = [0, 0, 1]$$$.
Java 8
standard input
[ "constructive algorithms", "number theory" ]
816a82bee65cf79ba8e4d61babcd0301
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in the tuple. The second line contains $$$n$$$ space separated prime numbers — the modules $$$p_1, p_2, \ldots, p_n$$$ ($$$2 \le p_i \le 2 \cdot 10^6$$$).
2,900
Print one integer — the maximum number of different tuples modulo $$$10^9 + 7$$$.
standard output
PASSED
636a49d74d9ae4aeb8142c5cfc578729
train_000.jsonl
1537707900
You are given a tuple generator $$$f^{(k)} = (f_1^{(k)}, f_2^{(k)}, \dots, f_n^{(k)})$$$, where $$$f_i^{(k)} = (a_i \cdot f_i^{(k - 1)} + b_i) \bmod p_i$$$ and $$$f^{(0)} = (x_1, x_2, \dots, x_n)$$$. Here $$$x \bmod y$$$ denotes the remainder of $$$x$$$ when divided by $$$y$$$. All $$$p_i$$$ are primes.One can see that...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.io.IOException; import java.util.Random; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import ...
Java
["4\n2 3 5 7", "3\n5 3 3"]
2 seconds
["210", "30"]
NoteIn the first example we can choose next parameters: $$$a = [1, 1, 1, 1]$$$, $$$b = [1, 1, 1, 1]$$$, $$$x = [0, 0, 0, 0]$$$, then $$$f_i^{(k)} = k \bmod p_i$$$.In the second example we can choose next parameters: $$$a = [1, 1, 2]$$$, $$$b = [1, 1, 0]$$$, $$$x = [0, 0, 1]$$$.
Java 8
standard input
[ "constructive algorithms", "number theory" ]
816a82bee65cf79ba8e4d61babcd0301
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in the tuple. The second line contains $$$n$$$ space separated prime numbers — the modules $$$p_1, p_2, \ldots, p_n$$$ ($$$2 \le p_i \le 2 \cdot 10^6$$$).
2,900
Print one integer — the maximum number of different tuples modulo $$$10^9 + 7$$$.
standard output
PASSED
5f91fb0f931846d67f5097176437b17f
train_000.jsonl
1537707900
You are given a tuple generator $$$f^{(k)} = (f_1^{(k)}, f_2^{(k)}, \dots, f_n^{(k)})$$$, where $$$f_i^{(k)} = (a_i \cdot f_i^{(k - 1)} + b_i) \bmod p_i$$$ and $$$f^{(0)} = (x_1, x_2, \dots, x_n)$$$. Here $$$x \bmod y$$$ denotes the remainder of $$$x$$$ when divided by $$$y$$$. All $$$p_i$$$ are primes.One can see that...
512 megabytes
import java.io.*; import java.math.*; import java.util.*; public class A { public static void main (String[] args) { new A(); } //tough math problem. most of the proof makes sense int MOD = (int)1e9+7; A() { Scanner s = new Scanner(System.in); System.err.println(""); int n = s.nextInt(); int max = 0; ...
Java
["4\n2 3 5 7", "3\n5 3 3"]
2 seconds
["210", "30"]
NoteIn the first example we can choose next parameters: $$$a = [1, 1, 1, 1]$$$, $$$b = [1, 1, 1, 1]$$$, $$$x = [0, 0, 0, 0]$$$, then $$$f_i^{(k)} = k \bmod p_i$$$.In the second example we can choose next parameters: $$$a = [1, 1, 2]$$$, $$$b = [1, 1, 0]$$$, $$$x = [0, 0, 1]$$$.
Java 8
standard input
[ "constructive algorithms", "number theory" ]
816a82bee65cf79ba8e4d61babcd0301
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in the tuple. The second line contains $$$n$$$ space separated prime numbers — the modules $$$p_1, p_2, \ldots, p_n$$$ ($$$2 \le p_i \le 2 \cdot 10^6$$$).
2,900
Print one integer — the maximum number of different tuples modulo $$$10^9 + 7$$$.
standard output
PASSED
733f818b18e87adcef95b62493c5e541
train_000.jsonl
1508054700
This is an interactive problem.Jury has hidden a permutation p of integers from 0 to n - 1. You know only the length n. Remind that in permutation all integers are distinct.Let b be the inverse permutation for p, i.e. pbi = i for all i. The only thing you can do is to ask xor of elements pi and bj, printing two indices...
256 megabytes
import java.io.*; import java.util.*; import java.io.*; import java.util.*; import java.math.*; public class B { public static void main(String[] args)throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); int xor[][] = new int[n][n]; fo...
Java
["3\n0\n0\n3\n2\n3\n2", "4\n2\n3\n2\n0\n2\n3\n2\n0"]
2 seconds
["? 0 0\n? 1 1\n? 1 2\n? 0 2\n? 2 1\n? 2 0\n!\n1\n0 1 2", "? 0 1\n? 1 2\n? 2 3\n? 3 3\n? 3 2\n? 2 1\n? 1 0\n? 0 0\n!\n2\n3 1 2 0"]
Notexor operation, or bitwise exclusive OR, is an operation performed over two integers, in which the i-th digit in binary representation of the result is equal to 1 if and only if exactly one of the two integers has the i-th digit in binary representation equal to 1. For more information, see here.In the first example...
Java 11
standard input
[ "implementation", "brute force", "interactive" ]
77b30da2a1df31ae74c07ab2002f0c71
The first line contains single integer n (1 ≤ n ≤ 5000) — the length of the hidden permutation. You should read this integer first.
2,000
When your program is ready to print the answer, print three lines. In the first line print "!". In the second line print single integer answers_cnt — the number of permutations indistinguishable from the hidden one, including the hidden one. In the third line print n integers p0, p1, ..., pn - 1 (0 ≤ pi &lt; n, all pi...
standard output
PASSED
52b671c2c8752b9c7664bf0bfe08b084
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.math.BigInteger; import java.util.Scanner; /* 527 4573 1357997531 2268482861 2268482869 4265 4263 */ public class b { public static void main(String[] args) { Scanner in = new Scanner(System.in); String n = in.next(); in.close(); // n = ""; // for(int i = 0; i < 1E5; ++i) // { ...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
5280fff29f7c099124e40ae666cffd2a
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String n = scan.next(); StringBuilder s = new StringBuilder(n); String ans = ""; int in = -1; int k = -1; for (int i = 0; i < n.length()...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
e141257dac949ddbf4268db1d25c53c4
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
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 * @author Xi Lin (zimpha@gmail.com) *...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
27aefd861b6a2885a7f0dcdecc0bf04c
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.util.Scanner; public class B { public static int toInt(char c) { return (int) c - '0'; } public static void main(String[] args) { Scanner in = new Scanner(System.in); char[] c = in.nextLine().toCharArray(); // SWAP SMALL int l = toInt(c[c.length - 1]), t; boolean found = false; for (int ...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
4b9d89c7b6181070f3e97f8902eec698
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.util.Scanner; public class B { private static char[] c; private static int len, l; public static int toInt(char c) { return (int) c - '0'; } public static boolean solve(int i) { if (i >= 0 && i < len) { int x = toInt(c[i]); if ((x & 1) == 0) { if (x < l) { char p = c[i]; c[i...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
0d6d48aefe49a6146b3c87733469b25f
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Queue; import java.util.Scanner; import java.util.Stack; public class Solution { public String currency() { Scanner s = new Scanner(System.in); char[] n = s.next().toCharArray(); s.close(); for (int i = 0;...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
4cdc23d4e75e20de86d43a6d347cdb85
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import static java.lang.System.in; import java.io.IOException; import java.util.*; public class Main {//static{ System.out.println("hello");} static byte[] buffer = new byte[8192]; static int offset = 0; static int bufferSize = 0; static void print(char a[]) {for (int i=0;i<a.length ;i++) ...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
7cb4134b6af1159d9f30c106c0cfdf29
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.util.Scanner; public class AntonandCurrencyYouAllKnow { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); String todayRate = sc.next(); char swap = todayRate.charAt(todayRate.length() - 1); ...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
2c0d475d2f1815ff72e7ae106becdecd
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main2 { public static void main(String args[]) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); boolean ok = false; int kouhoindex = ...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
5e4df66adad07f5b81db71092ac21fc2
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class AntonAndCurrency { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String input...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
734bba0ecf2ea95b1a6f8117bb8d377c
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.util.Scanner; /** * Created by yakoub on 13/04/15. */ public class CurrencyYouAllKnowAbout { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); String number = scanner.next(); int lastNumber = number.charAt(number.length()-1) - '0'; int ...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
0ccaedc5935d8f5eeb1e9757791468ea
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class B { public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); char[] c = bf.readLine().toCharArray(); boolean ff = false; int pos =...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
6ae9c9730e5325cd6c39047cb1f64e33
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.util.Scanner; public class AntonAndCurrencyYouAllKnow { @SuppressWarnings("resource") public static void main(String[] args) { Scanner scanner=new Scanner(System.in); String numString=scanner.nextLine(); int best=-1; int index=-1; int last=Integer.valueOf(numString.substring(numString.length()-1...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
178d8e705f5c87efefba066fb897e074
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.i...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
faf790473a1efc891605e1ed1a0f6781
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
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; import java.util.ArrayList; public class Main { public static void main(String[] args) { InputStream ...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
dd9dc780d1ed88011120ba2207bc72d9
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
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; import java.util.ArrayList; public class Main { public static void main(String[] args) { InputStream ...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
bb83bc952f6173be9ac3553d29cfdba0
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class CFB { public static void main(String[] args) { Scanner in = new Scanner(System.in); String n = in.next(); int minind = 0; int minv = 999999; int lv = ((int) (n.charAt(n.length()-1)))-48; StringBuilder res = new StringBuilder(n); for (...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
fb6a503f798551981c797d28a13e7c90
train_000.jsonl
1422376200
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Map; import java.util.TreeMap; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedRead...
Java
["527", "4573", "1357997531"]
0.5 seconds
["572", "3574", "-1"]
null
Java 7
standard input
[ "greedy", "math", "strings" ]
bc375e27bd52f413216aaecc674366f8
The first line contains an odd positive integer n — the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
1,300
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
standard output
PASSED
9f7def9dc65fbd12d1360f80591b4adb
train_000.jsonl
1475494500
Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence a1, a2, ..., an, where ai is a band, which performs the i-th song. Polycarp likes bands with the numbers from 1 to m, but he doesn't really like others. We define as bj the number of songs the gro...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static int find_less_than_avg(int arr[], int avg, int m){ for(int i = 1; i <= m; i++) if(arr[i] < avg) return i; return -1; } public static void process()throws IOException { ...
Java
["4 2\n1 2 3 2", "7 3\n1 3 2 2 2 2 1", "4 4\n1000000000 100 7 1000000000"]
2 seconds
["2 1\n1 2 1 2", "2 1\n1 3 3 2 2 2 1", "1 4\n1 2 3 4"]
NoteIn the first sample, after Polycarp's changes the first band performs two songs (b1 = 2), and the second band also performs two songs (b2 = 2). Thus, the minimum of these values equals to 2. It is impossible to achieve a higher minimum value by any changes in the playlist. In the second sample, after Polycarp's cha...
Java 11
standard input
[ "greedy" ]
0d89602f5ed765adf6807f86df1205bd
The first line of the input contains two integers n and m (1 ≤ m ≤ n ≤ 2000). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is the performer of the i-th song.
1,600
In the first line print two integers: the maximum possible value of the minimum among the bj (1 ≤ j ≤ m), where bj is the number of songs in the changed playlist performed by the j-th band, and the minimum number of changes in the playlist Polycarp needs to make. In the second line print the changed playlist. If there ...
standard output
PASSED
f091070b08a221d54f4fea4c38144533
train_000.jsonl
1475494500
Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence a1, a2, ..., an, where ai is a band, which performs the i-th song. Polycarp likes bands with the numbers from 1 to m, but he doesn't really like others. We define as bj the number of songs the gro...
256 megabytes
import java.util.*; import java.io.*; public class PolycarpattheRadio { // https://codeforces.com/contest/723/problem/C public static void main(String[] args) throws IOException, FileNotFoundException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); //BufferedReader in = new Buffer...
Java
["4 2\n1 2 3 2", "7 3\n1 3 2 2 2 2 1", "4 4\n1000000000 100 7 1000000000"]
2 seconds
["2 1\n1 2 1 2", "2 1\n1 3 3 2 2 2 1", "1 4\n1 2 3 4"]
NoteIn the first sample, after Polycarp's changes the first band performs two songs (b1 = 2), and the second band also performs two songs (b2 = 2). Thus, the minimum of these values equals to 2. It is impossible to achieve a higher minimum value by any changes in the playlist. In the second sample, after Polycarp's cha...
Java 11
standard input
[ "greedy" ]
0d89602f5ed765adf6807f86df1205bd
The first line of the input contains two integers n and m (1 ≤ m ≤ n ≤ 2000). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is the performer of the i-th song.
1,600
In the first line print two integers: the maximum possible value of the minimum among the bj (1 ≤ j ≤ m), where bj is the number of songs in the changed playlist performed by the j-th band, and the minimum number of changes in the playlist Polycarp needs to make. In the second line print the changed playlist. If there ...
standard output
PASSED
a6c6cdb2ffa74bb0e8cbd4a7a2bc2373
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
// TO LOVE IS TO KNOW WHAT'S YOUR WORTH. // // Author :- Saurabh// //BIT MESRA, RANCHI// import java.io.*; import java.util.*; import static java.lang.Math.*; public class minimumInteger { static void Bolo_Jai_Mata_Di() { t = ni(); tsc(); // starting time of execution while(t-->0){...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
c2ee4d4830d309b4c98834f88eaf5cb1
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.Scanner; public class minint { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while (t-- > 0) { int l = scn.nextInt(); int r = scn.nextInt(); int d = scn.nextInt(); if (d < l || d > r) { ...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
f73621da36a8c9a96450a0d705bafc83
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.*; public class IUPC { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++) { int l=sc.nextInt(); int r=sc.nextInt(); long d=sc.nextLong(); long a=d; long m=1; int flag=1; while(a<l) { if(a%d==0) { if(...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
66c04ea9f6e77ccabcfb60bd3975e005
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner in=new Scanner(System.in); int q=in.nextInt(); for(int i=0;i<q;i++) { int l=in.nextInt(); int r=in.nextInt(); int d=in.nextInt(); if(l-d>0) System.out.println(d); else { System.out.println...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
59be7cd667508843ed9e9c04f49e03eb
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner in=new Scanner(System.in); int q=in.nextInt(); for(int i=0;i<q;i++) { int l=in.nextInt(); int r=in.nextInt(); int d=in.nextInt(); if(l-d>0) System.out.println(d); else { if(r<d) { S...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
9bece68df5b3617e72f4295c96cb6f0f
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; Outp...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
c2b26e4ff279723d98dff46a88de1e42
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; Outp...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
ad8551ab631ff41c3f3cd7fb5e30ba59
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { BufferedReader bf = new BufferedReader(...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
dfd3562779d57d0f74c4d521445f4aa8
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.Scanner; public class juego{ public static void main(String[] args){ Scanner lector = new Scanner(System.in); String optionx = lector.nextLine(); int option = Integer.parseInt(optionx); for(int i = 0; i < option; i++){ String optiony = lector.nextLine(); String[] div = optiony.split(...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
3e59a1b78de561da04e8db702961edcd
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.Scanner; public class ayhbl { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int l,r,d; loop :for(int i=0;i<n;i++) { l=in.nextInt(); r=in.nextInt(); d=in.nextInt(); if(d<l||d>r) System.out.println(d); else { int x=(...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
aff610c21aa18864ad432f86c45bb55c
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
3b3d4c11268432c91aa00d96ab1cbbcb
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
1aace63f3fd7f9d2910c01429d70a965
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.*; public class Class2 { public static void main(String[] args) { Scanner temp = new Scanner(System.in); int counter = 0; int queries = temp.nextInt(); int list[] = new int[queries]; //System.out.println(queries); while(counter<queries) { int l = temp.nextInt(); int r = tem...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
2fc7959df9a95b12d1508232fd2d0c53
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { public static void main (String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int i=0; for(int j=0;j<n;j++) { int a=s.nextInt(); int b=s.nextInt(); ...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
ac12ca0ec65b16c6e5f459e16f2a9de6
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.Scanner; public class CF1101_D2_A { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); for (int i = 0; i < n; i++) { solve(scanner); } } private static void solve(Scanner scanner) { ...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
854a725730d9e7b98df9b1e0c9b2b21f
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.Scanner; public class CF1101_D2_A { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); for (int i = 0; i < n; i++) { solve(scanner); } } private static void solve(Scanner scanner) { ...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
7c5f5c46b7552596531addfbfcb39027
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.Scanner; public class one { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while (n-->0) { int l=sc.nextInt(),r=sc.nextInt(),d=sc.nextInt(); int x=d; if (x>=l&&x<=r) { ...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
1abb5c1eed50a176e27c37913eec393c
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next() throws IOException { if (!tok.hasMoreToke...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
25701ef90deaf5f415ac2c3393b549e2
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
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 Main { PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
983a304ef91b5ed03cc90dfd0e1475d4
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.Scanner; public class JavaApplication61 { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); for(int i=0;i<n;i++){ int l=input.nextInt(); int r=input.nextInt(); int d=input.nextInt(); ...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
09044bdd4e300da4d1d814bec39ffd42
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.Scanner; public class EduDiv2Task2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int q = in.nextInt(); int l, r, d; int num = 1; int count = 0; int[] arr = new int[q]; while (q > 0){ l = in....
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
4db7353ceb63a862d573f6323d4fd566
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.Scanner; /** * * @author Hp */ public class Force2 { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input = new Scanner(System.in); long t= input.nextLong(); for ( long i = 0; i < t; i++) { ...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
2860f3aaf9c68df8b7e21644d412837d
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.Scanner; public class MinInt { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int q = scanner.nextInt(); int l[] = new int[q]; int r[] = new int[q]; int d[] = new int[q]; for (int i = 0; i < q; i++){ l[...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
8c001ada9538b652f53fa04d88500873
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.*; public class pairs { public static void main(String[] args) { Scanner s = new Scanner(System.in); long q = s.nextLong(); for(int i=0;i<(int)q;i++) { long l = s.nextLong(); long r = s.nextLong(); long d = s.nextLong(); ...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
47c31d39927895524b6f536185a6be89
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class Con1{ public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int q=sc.nextInt(); while(q-->0) { ...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
fddb2566033ea633cdef224deb899250
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.io.*; import java.util.*; public class Sirius { static BufferedReader br; static StringTokenizer st = new StringTokenizer(""); static int nextInt() throws IOException { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return Integer.p...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
643d05204bf72ff5446a46d87010451b
train_000.jsonl
1547217300
You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segmen...
256 megabytes
import java.util.Scanner; public class SolutionCF1101A { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int q = scan.nextInt(); for (int i = 0; i < q; i++) { int l = scan.nextInt(); int r = scan.nextInt(); i...
Java
["5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5"]
1 second
["6\n4\n1\n3\n10"]
null
Java 8
standard input
[ "math" ]
091e91352973b18040e2d57c46f2bf8a
The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.
1,000
For each query print one integer: the answer to this query.
standard output
PASSED
717f4df48dbacb4ce2bec7baa2cfc24f
train_000.jsonl
1587653100
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $$$n$$$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to pl...
256 megabytes
import java.io.*; import java.util.*; /* procrastinating */ public class Main { static FastReader in; static PrintWriter out; static Random rand = new Random(); static final int INF = (int) (1e9 + 10), MOD = (int) (1e9 + 7), LOGN = 60; static final long IINF = (long) (2e18 + 10); static clas...
Java
["15 5\n0 3 7 14 15\n11 11", "13 4\n0 3 7 13\n9 9"]
1 second
["45", "-1"]
NoteIn the first test, the optimal route is:      for the first green light, go to $$$7$$$ and return to $$$3$$$. In this case, we will change the direction of movement at the point $$$7$$$, which is allowed, since there is a safety island at this point. In the end, we will be at the point of $$$3$$$, where there is a...
Java 8
standard input
[ "implementation", "graphs", "shortest paths" ]
64625b26514984c4425c2813612115b3
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n \leq 10^6, 2 \leq m \leq min(n + 1, 10^4))$$$  — road width and the number of safety islands. The second line contains $$$m$$$ distinct integers $$$d_1, d_2, \ldots, d_m$$$ $$$(0 \leq d_i \leq n)$$$  — the points where the safety islands are located....
2,400
Output a single integer  — the minimum time for which Denis can cross the road with obeying all the rules. If it is impossible to cross the road output $$$-1$$$.
standard output
PASSED
bf18b12fac907e49706064932faae78d
train_000.jsonl
1587653100
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $$$n$$$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to pl...
256 megabytes
import java.io.*; import java.util.*; /* procrastinating */ public class Main { static FastReader in; static PrintWriter out; static Random rand = new Random(); static final int INF = (int) (1e9 + 10), MOD = (int) (1e9 + 7), LOGN = 60; static final long IINF = (long) (2e18 + 10); static clas...
Java
["15 5\n0 3 7 14 15\n11 11", "13 4\n0 3 7 13\n9 9"]
1 second
["45", "-1"]
NoteIn the first test, the optimal route is:      for the first green light, go to $$$7$$$ and return to $$$3$$$. In this case, we will change the direction of movement at the point $$$7$$$, which is allowed, since there is a safety island at this point. In the end, we will be at the point of $$$3$$$, where there is a...
Java 8
standard input
[ "implementation", "graphs", "shortest paths" ]
64625b26514984c4425c2813612115b3
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n \leq 10^6, 2 \leq m \leq min(n + 1, 10^4))$$$  — road width and the number of safety islands. The second line contains $$$m$$$ distinct integers $$$d_1, d_2, \ldots, d_m$$$ $$$(0 \leq d_i \leq n)$$$  — the points where the safety islands are located....
2,400
Output a single integer  — the minimum time for which Denis can cross the road with obeying all the rules. If it is impossible to cross the road output $$$-1$$$.
standard output
PASSED
db21d04edb4c5ef152c833408a143119
train_000.jsonl
1587653100
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $$$n$$$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to pl...
256 megabytes
/** * @author derrick20 */ import java.io.*; import java.lang.reflect.Array; import java.util.*; public class UnexpectedGuestREDO { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int N = sc.next...
Java
["15 5\n0 3 7 14 15\n11 11", "13 4\n0 3 7 13\n9 9"]
1 second
["45", "-1"]
NoteIn the first test, the optimal route is:      for the first green light, go to $$$7$$$ and return to $$$3$$$. In this case, we will change the direction of movement at the point $$$7$$$, which is allowed, since there is a safety island at this point. In the end, we will be at the point of $$$3$$$, where there is a...
Java 8
standard input
[ "implementation", "graphs", "shortest paths" ]
64625b26514984c4425c2813612115b3
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n \leq 10^6, 2 \leq m \leq min(n + 1, 10^4))$$$  — road width and the number of safety islands. The second line contains $$$m$$$ distinct integers $$$d_1, d_2, \ldots, d_m$$$ $$$(0 \leq d_i \leq n)$$$  — the points where the safety islands are located....
2,400
Output a single integer  — the minimum time for which Denis can cross the road with obeying all the rules. If it is impossible to cross the road output $$$-1$$$.
standard output
PASSED
b89d58dfb1c6ee6b8a3e89661b086b22
train_000.jsonl
1587653100
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $$$n$$$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to pl...
256 megabytes
import java.io.*; import java.util.*; public class E { public static void main(String... args) { FastScanner sc = new FastScanner(); int n = sc.nextInt(); int m = sc.nextInt(); ArrayList<Integer> arr = new ArrayList<Integer>(); for(int i = 0; i < m; i++) arr.add(sc.nextInt()); Collections.sort(arr); in...
Java
["15 5\n0 3 7 14 15\n11 11", "13 4\n0 3 7 13\n9 9"]
1 second
["45", "-1"]
NoteIn the first test, the optimal route is:      for the first green light, go to $$$7$$$ and return to $$$3$$$. In this case, we will change the direction of movement at the point $$$7$$$, which is allowed, since there is a safety island at this point. In the end, we will be at the point of $$$3$$$, where there is a...
Java 8
standard input
[ "implementation", "graphs", "shortest paths" ]
64625b26514984c4425c2813612115b3
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n \leq 10^6, 2 \leq m \leq min(n + 1, 10^4))$$$  — road width and the number of safety islands. The second line contains $$$m$$$ distinct integers $$$d_1, d_2, \ldots, d_m$$$ $$$(0 \leq d_i \leq n)$$$  — the points where the safety islands are located....
2,400
Output a single integer  — the minimum time for which Denis can cross the road with obeying all the rules. If it is impossible to cross the road output $$$-1$$$.
standard output
PASSED
94c3c6b33ff4f21ae2aae8da6d7b0c2c
train_000.jsonl
1587653100
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $$$n$$$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to pl...
256 megabytes
import java.io.*; import java.util.*; import java.util.zip.Adler32; public class Contest1 { static class node implements Comparable<node> { int idx, time; int cost; public node(int a, int b, int c) { idx = a; time = b; cost = c; } @Over...
Java
["15 5\n0 3 7 14 15\n11 11", "13 4\n0 3 7 13\n9 9"]
1 second
["45", "-1"]
NoteIn the first test, the optimal route is:      for the first green light, go to $$$7$$$ and return to $$$3$$$. In this case, we will change the direction of movement at the point $$$7$$$, which is allowed, since there is a safety island at this point. In the end, we will be at the point of $$$3$$$, where there is a...
Java 8
standard input
[ "implementation", "graphs", "shortest paths" ]
64625b26514984c4425c2813612115b3
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n \leq 10^6, 2 \leq m \leq min(n + 1, 10^4))$$$  — road width and the number of safety islands. The second line contains $$$m$$$ distinct integers $$$d_1, d_2, \ldots, d_m$$$ $$$(0 \leq d_i \leq n)$$$  — the points where the safety islands are located....
2,400
Output a single integer  — the minimum time for which Denis can cross the road with obeying all the rules. If it is impossible to cross the road output $$$-1$$$.
standard output
PASSED
f459e339756ee5d997eea1cdf60f0da4
train_000.jsonl
1587653100
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $$$n$$$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to pl...
256 megabytes
import java.io.*; import java.util.*; public class Sol2{ static class node { private int idx; private int time; public node(int idx, int time) { this.idx = idx; this.time = time; if(this.time==g) this.time=0; } } public static int n, g, r, m; public static int arr[]; public static int dist[][]; ...
Java
["15 5\n0 3 7 14 15\n11 11", "13 4\n0 3 7 13\n9 9"]
1 second
["45", "-1"]
NoteIn the first test, the optimal route is:      for the first green light, go to $$$7$$$ and return to $$$3$$$. In this case, we will change the direction of movement at the point $$$7$$$, which is allowed, since there is a safety island at this point. In the end, we will be at the point of $$$3$$$, where there is a...
Java 8
standard input
[ "implementation", "graphs", "shortest paths" ]
64625b26514984c4425c2813612115b3
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n \leq 10^6, 2 \leq m \leq min(n + 1, 10^4))$$$  — road width and the number of safety islands. The second line contains $$$m$$$ distinct integers $$$d_1, d_2, \ldots, d_m$$$ $$$(0 \leq d_i \leq n)$$$  — the points where the safety islands are located....
2,400
Output a single integer  — the minimum time for which Denis can cross the road with obeying all the rules. If it is impossible to cross the road output $$$-1$$$.
standard output
PASSED
87474ab58a862ed6ef9e981941926519
train_000.jsonl
1587653100
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $$$n$$$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to pl...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** If I'm the sun, you're the moon Because when I go up, you go down ******************************* I'm working for the day I will surpass you https://www.a2oj.com/Ladder16.html */ impor...
Java
["15 5\n0 3 7 14 15\n11 11", "13 4\n0 3 7 13\n9 9"]
1 second
["45", "-1"]
NoteIn the first test, the optimal route is:      for the first green light, go to $$$7$$$ and return to $$$3$$$. In this case, we will change the direction of movement at the point $$$7$$$, which is allowed, since there is a safety island at this point. In the end, we will be at the point of $$$3$$$, where there is a...
Java 8
standard input
[ "implementation", "graphs", "shortest paths" ]
64625b26514984c4425c2813612115b3
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n \leq 10^6, 2 \leq m \leq min(n + 1, 10^4))$$$  — road width and the number of safety islands. The second line contains $$$m$$$ distinct integers $$$d_1, d_2, \ldots, d_m$$$ $$$(0 \leq d_i \leq n)$$$  — the points where the safety islands are located....
2,400
Output a single integer  — the minimum time for which Denis can cross the road with obeying all the rules. If it is impossible to cross the road output $$$-1$$$.
standard output
PASSED
e779c93dfb1e4bf34dd17ab6d7c2fccf
train_000.jsonl
1587653100
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $$$n$$$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to pl...
256 megabytes
// Working program with FastReader import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import javafx.util.Pair; public class Problem5 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() ...
Java
["15 5\n0 3 7 14 15\n11 11", "13 4\n0 3 7 13\n9 9"]
1 second
["45", "-1"]
NoteIn the first test, the optimal route is:      for the first green light, go to $$$7$$$ and return to $$$3$$$. In this case, we will change the direction of movement at the point $$$7$$$, which is allowed, since there is a safety island at this point. In the end, we will be at the point of $$$3$$$, where there is a...
Java 8
standard input
[ "implementation", "graphs", "shortest paths" ]
64625b26514984c4425c2813612115b3
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n \leq 10^6, 2 \leq m \leq min(n + 1, 10^4))$$$  — road width and the number of safety islands. The second line contains $$$m$$$ distinct integers $$$d_1, d_2, \ldots, d_m$$$ $$$(0 \leq d_i \leq n)$$$  — the points where the safety islands are located....
2,400
Output a single integer  — the minimum time for which Denis can cross the road with obeying all the rules. If it is impossible to cross the road output $$$-1$$$.
standard output
PASSED
1a110c87f5b4fb7852f09500c153e53b
train_000.jsonl
1587653100
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $$$n$$$ lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to pl...
256 megabytes
import java.util.*; import java.io.*; public class E { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer token = new StringTokenizer(in.readLine()); int n = Integer.parseInt(token.nextToken()); int m = Integer....
Java
["15 5\n0 3 7 14 15\n11 11", "13 4\n0 3 7 13\n9 9"]
1 second
["45", "-1"]
NoteIn the first test, the optimal route is:      for the first green light, go to $$$7$$$ and return to $$$3$$$. In this case, we will change the direction of movement at the point $$$7$$$, which is allowed, since there is a safety island at this point. In the end, we will be at the point of $$$3$$$, where there is a...
Java 8
standard input
[ "implementation", "graphs", "shortest paths" ]
64625b26514984c4425c2813612115b3
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n \leq 10^6, 2 \leq m \leq min(n + 1, 10^4))$$$  — road width and the number of safety islands. The second line contains $$$m$$$ distinct integers $$$d_1, d_2, \ldots, d_m$$$ $$$(0 \leq d_i \leq n)$$$  — the points where the safety islands are located....
2,400
Output a single integer  — the minimum time for which Denis can cross the road with obeying all the rules. If it is impossible to cross the road output $$$-1$$$.
standard output
PASSED
c29963ebe6502bcc2e73b1f8df4a6b3d
train_000.jsonl
1484235300
It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other cities. Since Bash wants to surprise his friends, he decides to send a Pikachu ...
512 megabytes
import java.io.*; import java.util.*; public class Test { int readInt() { int ans = 0; boolean neg = false; try { boolean start = false; for (int c = 0; (c = System.in.read()) != -1; ) { if (c == '-') { start = true; ...
Java
["4 4 3\n1 2 1\n2 3 1\n2 4 1\n3 1 1", "7 11 2\n1 2 5\n1 3 5\n2 4 2\n2 5 2\n3 6 3\n3 7 3\n4 6 2\n3 4 2\n6 7 3\n4 5 7\n4 7 7"]
2.5 seconds
["2", "4"]
NoteIn the first sample, on destroying the city 2, the length of shortest distance between pairs of cities (3, 2) and (3, 4) will change. Hence the answer is 2.
Java 8
standard input
[ "data structures", "graphs", "shortest paths" ]
c47d0c9a429030c4b5d6f5605be36c75
The first line contains three space separated integers n, m and s (2 ≤ n ≤ 2·105, , 1 ≤ s ≤ n) — the number of cities and the number of roads in the Himalayan region and the city Bash lives in. Each of the next m lines contain three space-separated integers u, v and w (1 ≤ u, v ≤ n, u ≠ v, 1 ≤ w ≤ 109) denoting that th...
2,800
Print a single integer, the answer to the problem.
standard output
PASSED
3babcbfe87a5fe404de33515bff9d6fa
train_000.jsonl
1484235300
It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other cities. Since Bash wants to surprise his friends, he decides to send a Pikachu ...
512 megabytes
import java.io.*; import java.util.*; public class Test { int readInt() { int ans = 0; boolean neg = false; try { boolean start = false; for (int c = 0; (c = System.in.read()) != -1; ) { if (c == '-') { start = true; ...
Java
["4 4 3\n1 2 1\n2 3 1\n2 4 1\n3 1 1", "7 11 2\n1 2 5\n1 3 5\n2 4 2\n2 5 2\n3 6 3\n3 7 3\n4 6 2\n3 4 2\n6 7 3\n4 5 7\n4 7 7"]
2.5 seconds
["2", "4"]
NoteIn the first sample, on destroying the city 2, the length of shortest distance between pairs of cities (3, 2) and (3, 4) will change. Hence the answer is 2.
Java 8
standard input
[ "data structures", "graphs", "shortest paths" ]
c47d0c9a429030c4b5d6f5605be36c75
The first line contains three space separated integers n, m and s (2 ≤ n ≤ 2·105, , 1 ≤ s ≤ n) — the number of cities and the number of roads in the Himalayan region and the city Bash lives in. Each of the next m lines contain three space-separated integers u, v and w (1 ≤ u, v ≤ n, u ≠ v, 1 ≤ w ≤ 109) denoting that th...
2,800
Print a single integer, the answer to the problem.
standard output
PASSED
aa2941fc2e35431b65e70db6eca8178b
train_000.jsonl
1484235300
It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other cities. Since Bash wants to surprise his friends, he decides to send a Pikachu ...
512 megabytes
import java.io.*; import java.util.*; public class Test { int readInt() { int ans = 0; boolean neg = false; try { boolean start = false; for (int c = 0; (c = System.in.read()) != -1; ) { if (c == '-') { start = true; ...
Java
["4 4 3\n1 2 1\n2 3 1\n2 4 1\n3 1 1", "7 11 2\n1 2 5\n1 3 5\n2 4 2\n2 5 2\n3 6 3\n3 7 3\n4 6 2\n3 4 2\n6 7 3\n4 5 7\n4 7 7"]
2.5 seconds
["2", "4"]
NoteIn the first sample, on destroying the city 2, the length of shortest distance between pairs of cities (3, 2) and (3, 4) will change. Hence the answer is 2.
Java 8
standard input
[ "data structures", "graphs", "shortest paths" ]
c47d0c9a429030c4b5d6f5605be36c75
The first line contains three space separated integers n, m and s (2 ≤ n ≤ 2·105, , 1 ≤ s ≤ n) — the number of cities and the number of roads in the Himalayan region and the city Bash lives in. Each of the next m lines contain three space-separated integers u, v and w (1 ≤ u, v ≤ n, u ≠ v, 1 ≤ w ≤ 109) denoting that th...
2,800
Print a single integer, the answer to the problem.
standard output
PASSED
c28cae450c8d2c6ca0a69c3d9791344e
train_000.jsonl
1484235300
It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other cities. Since Bash wants to surprise his friends, he decides to send a Pikachu ...
512 megabytes
import java.io.*; import java.util.*; public class Test { int readInt() { int ans = 0; boolean neg = false; try { boolean start = false; for (int c = 0; (c = System.in.read()) != -1; ) { if (c == '-') { start = true; ...
Java
["4 4 3\n1 2 1\n2 3 1\n2 4 1\n3 1 1", "7 11 2\n1 2 5\n1 3 5\n2 4 2\n2 5 2\n3 6 3\n3 7 3\n4 6 2\n3 4 2\n6 7 3\n4 5 7\n4 7 7"]
2.5 seconds
["2", "4"]
NoteIn the first sample, on destroying the city 2, the length of shortest distance between pairs of cities (3, 2) and (3, 4) will change. Hence the answer is 2.
Java 8
standard input
[ "data structures", "graphs", "shortest paths" ]
c47d0c9a429030c4b5d6f5605be36c75
The first line contains three space separated integers n, m and s (2 ≤ n ≤ 2·105, , 1 ≤ s ≤ n) — the number of cities and the number of roads in the Himalayan region and the city Bash lives in. Each of the next m lines contain three space-separated integers u, v and w (1 ≤ u, v ≤ n, u ≠ v, 1 ≤ w ≤ 109) denoting that th...
2,800
Print a single integer, the answer to the problem.
standard output
PASSED
52a09fc8e2b5dd060ae78c1bbd810f24
train_000.jsonl
1484235300
It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other cities. Since Bash wants to surprise his friends, he decides to send a Pikachu ...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.AbstractSet; import java.util.InputMismatchException; import java.util.Random; import java.util.Map; import java.io.OutputStreamWriter; import java.util.NoSuchElementException; import java.io.O...
Java
["4 4 3\n1 2 1\n2 3 1\n2 4 1\n3 1 1", "7 11 2\n1 2 5\n1 3 5\n2 4 2\n2 5 2\n3 6 3\n3 7 3\n4 6 2\n3 4 2\n6 7 3\n4 5 7\n4 7 7"]
2.5 seconds
["2", "4"]
NoteIn the first sample, on destroying the city 2, the length of shortest distance between pairs of cities (3, 2) and (3, 4) will change. Hence the answer is 2.
Java 8
standard input
[ "data structures", "graphs", "shortest paths" ]
c47d0c9a429030c4b5d6f5605be36c75
The first line contains three space separated integers n, m and s (2 ≤ n ≤ 2·105, , 1 ≤ s ≤ n) — the number of cities and the number of roads in the Himalayan region and the city Bash lives in. Each of the next m lines contain three space-separated integers u, v and w (1 ≤ u, v ≤ n, u ≠ v, 1 ≤ w ≤ 109) denoting that th...
2,800
Print a single integer, the answer to the problem.
standard output
PASSED
8873e2538dacd9e3f45854b1118d055f
train_000.jsonl
1484235300
It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other cities. Since Bash wants to surprise his friends, he decides to send a Pikachu ...
512 megabytes
//package round391; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class F2 { InputStream is; PrintWriter out; String INPUT = ""; public static class DJSet { public...
Java
["4 4 3\n1 2 1\n2 3 1\n2 4 1\n3 1 1", "7 11 2\n1 2 5\n1 3 5\n2 4 2\n2 5 2\n3 6 3\n3 7 3\n4 6 2\n3 4 2\n6 7 3\n4 5 7\n4 7 7"]
2.5 seconds
["2", "4"]
NoteIn the first sample, on destroying the city 2, the length of shortest distance between pairs of cities (3, 2) and (3, 4) will change. Hence the answer is 2.
Java 8
standard input
[ "data structures", "graphs", "shortest paths" ]
c47d0c9a429030c4b5d6f5605be36c75
The first line contains three space separated integers n, m and s (2 ≤ n ≤ 2·105, , 1 ≤ s ≤ n) — the number of cities and the number of roads in the Himalayan region and the city Bash lives in. Each of the next m lines contain three space-separated integers u, v and w (1 ≤ u, v ≤ n, u ≠ v, 1 ≤ w ≤ 109) denoting that th...
2,800
Print a single integer, the answer to the problem.
standard output
PASSED
11d0797d025798b463b697fc876eb567
train_000.jsonl
1484235300
It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other cities. Since Bash wants to surprise his friends, he decides to send a Pikachu ...
512 megabytes
//package round391; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.List; import java.util.Queue; public c...
Java
["4 4 3\n1 2 1\n2 3 1\n2 4 1\n3 1 1", "7 11 2\n1 2 5\n1 3 5\n2 4 2\n2 5 2\n3 6 3\n3 7 3\n4 6 2\n3 4 2\n6 7 3\n4 5 7\n4 7 7"]
2.5 seconds
["2", "4"]
NoteIn the first sample, on destroying the city 2, the length of shortest distance between pairs of cities (3, 2) and (3, 4) will change. Hence the answer is 2.
Java 8
standard input
[ "data structures", "graphs", "shortest paths" ]
c47d0c9a429030c4b5d6f5605be36c75
The first line contains three space separated integers n, m and s (2 ≤ n ≤ 2·105, , 1 ≤ s ≤ n) — the number of cities and the number of roads in the Himalayan region and the city Bash lives in. Each of the next m lines contain three space-separated integers u, v and w (1 ≤ u, v ≤ n, u ≠ v, 1 ≤ w ≤ 109) denoting that th...
2,800
Print a single integer, the answer to the problem.
standard output
PASSED
7a0f31871fb9927cef03b09e27d9ea5f
train_000.jsonl
1484235300
It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other cities. Since Bash wants to surprise his friends, he decides to send a Pikachu ...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.PriorityQueue; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; ...
Java
["4 4 3\n1 2 1\n2 3 1\n2 4 1\n3 1 1", "7 11 2\n1 2 5\n1 3 5\n2 4 2\n2 5 2\n3 6 3\n3 7 3\n4 6 2\n3 4 2\n6 7 3\n4 5 7\n4 7 7"]
2.5 seconds
["2", "4"]
NoteIn the first sample, on destroying the city 2, the length of shortest distance between pairs of cities (3, 2) and (3, 4) will change. Hence the answer is 2.
Java 8
standard input
[ "data structures", "graphs", "shortest paths" ]
c47d0c9a429030c4b5d6f5605be36c75
The first line contains three space separated integers n, m and s (2 ≤ n ≤ 2·105, , 1 ≤ s ≤ n) — the number of cities and the number of roads in the Himalayan region and the city Bash lives in. Each of the next m lines contain three space-separated integers u, v and w (1 ≤ u, v ≤ n, u ≠ v, 1 ≤ w ≤ 109) denoting that th...
2,800
Print a single integer, the answer to the problem.
standard output