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 | 060803f2fb8bfd431c3c7c56d3a34b72 | train_003.jsonl | 1590327300 | You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i... | 256 megabytes | // Working program with FastReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class problem6
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = ne... | Java | ["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"] | 2 seconds | ["abab\n-1\naaa\nab\nz"] | NoteThe first test case was explained in the statement.In the second test case, the answer does not exist. | Java 11 | standard input | [
"dp",
"hashing",
"constructive algorithms",
"bitmasks",
"brute force",
"strings"
] | 8d4cdf75f726b59a8fcc374e1417374a | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$) — the number of strings and their length. Then follow $$$n$$... | 1,700 | Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes). | standard output | |
PASSED | 28a0fbfa6a023a9a5fb322b115a0f3fd | train_003.jsonl | 1590327300 | You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in Actual solution is at the top
*
* @author dauom... | Java | ["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"] | 2 seconds | ["abab\n-1\naaa\nab\nz"] | NoteThe first test case was explained in the statement.In the second test case, the answer does not exist. | Java 11 | standard input | [
"dp",
"hashing",
"constructive algorithms",
"bitmasks",
"brute force",
"strings"
] | 8d4cdf75f726b59a8fcc374e1417374a | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$) — the number of strings and their length. Then follow $$$n$$... | 1,700 | Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes). | standard output | |
PASSED | 9b1f36c001e786044b74514a3fabae0a | train_003.jsonl | 1590327300 | You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i... | 256 megabytes | //package round644;
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 F {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
for(int T = ni();T ... | Java | ["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"] | 2 seconds | ["abab\n-1\naaa\nab\nz"] | NoteThe first test case was explained in the statement.In the second test case, the answer does not exist. | Java 11 | standard input | [
"dp",
"hashing",
"constructive algorithms",
"bitmasks",
"brute force",
"strings"
] | 8d4cdf75f726b59a8fcc374e1417374a | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$) — the number of strings and their length. Then follow $$$n$$... | 1,700 | Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes). | standard output | |
PASSED | d469efa835131a4722ac46fac177eacf | train_003.jsonl | 1590327300 | You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i... | 256 megabytes | import java.util.ArrayList;
import java.util.Scanner;
public class Main {
private static int numDiffs(String word, String word2) {
int len = word.length();
int result = 0;
for (int i = 0; i < len; i++) {
if (word.charAt(i) != word2.charAt(i)) result++;
}
return... | Java | ["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"] | 2 seconds | ["abab\n-1\naaa\nab\nz"] | NoteThe first test case was explained in the statement.In the second test case, the answer does not exist. | Java 11 | standard input | [
"dp",
"hashing",
"constructive algorithms",
"bitmasks",
"brute force",
"strings"
] | 8d4cdf75f726b59a8fcc374e1417374a | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$) — the number of strings and their length. Then follow $$$n$$... | 1,700 | Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes). | standard output | |
PASSED | a01971a46d02f1c6b5c169c17435df2f | train_003.jsonl | 1590327300 | You are given $$$n$$$ strings $$$a_1, a_2, \ldots, a_n$$$: all of them have the same length $$$m$$$. The strings consist of lowercase English letters.Find any string $$$s$$$ of length $$$m$$$ such that each of the given $$$n$$$ strings differs from $$$s$$$ in at most one position. Formally, for each given string $$$a_i... | 256 megabytes | import java.util.Scanner;
import java.util.*;
public class file {
private static final Scanner scn = new Scanner(System.in);
private static int cmp(char[] s1, char[] s2) {
int diff = 0;
for (int i = 0; i < s1.length; i++) {
diff += Math.abs(s1[i] - s2[i]);
}
return diff;
}
pr... | Java | ["5\n2 4\nabac\nzbab\n2 4\naaaa\nbbbb\n3 3\nbaa\naaa\naab\n2 2\nab\nbb\n3 1\na\nb\nc"] | 2 seconds | ["abab\n-1\naaa\nab\nz"] | NoteThe first test case was explained in the statement.In the second test case, the answer does not exist. | Java 11 | standard input | [
"dp",
"hashing",
"constructive algorithms",
"bitmasks",
"brute force",
"strings"
] | 8d4cdf75f726b59a8fcc374e1417374a | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case starts with a line containing two positive integers $$$n$$$ ($$$1 \le n \le 10$$$) and $$$m$$$ ($$$1 \le m \le 10$$$) — the number of strings and their length. Then follow $$$n$$... | 1,700 | Print $$$t$$$ answers to the test cases. Each answer (if it exists) is a string of length $$$m$$$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes). | standard output | |
PASSED | 0495898138d63060dedc14d5462e41cd | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.*;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
public class Main {
static final int mod = 1000000007;
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter ... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | cf74da89fa4185deea2ded3307565d47 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class TavasMalekas {
static final int MOD = (int) (1e9 + 7);
void solve() {
int n = in.nextInt(), m = in.nextInt(... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | ffc1fddb0f1d81fd9ac3284b2ac83457 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class Malekas {
static final int MOD = (int) (1e9 + 7);
void solve() {
int n = in.nextInt(), m = in.nextInt();
... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | c8c32cda7e51f19d36daa84ef47b6fc2 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes |
import java.util.*;
import java.io.*;
/**
*
* @author usquare
*
*/
public class ProblemB {
public static int mod = 1000000007;
public static int[] getZ(char pat[]){
int n = pat.length;
int z[] = new int[n];
int l = 0,r = 0;
for(int i=1;i<n;i++){
i... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | b9e876e5d2514ad1b52b6e41d0201df3 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.*;
import java.util.*;
public class CF535D {
static long pow(int k) {
return k == 0 ? 1 : pow(k - 1) * 26 % 1000000007;
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenize... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 4d30712a4f8240f1e86fc560b5a6a0b7 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main {
public static int mod=1000000007, NN=1000010;
public static long pow(int k) {
long ans=1, x=26;
for(; k>0; k>>=1, x=x*x%mod) if(k%2==1) ans=x*ans%mod;
return ans;
}
public static int min( int... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | dd18361a066cf594d268f90bcdf6cb28 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main {
public static int mod=1000000007, NN=1000010;
public static long pow(int k) {
long ans=1, x=26;
for(; k>0; k>>=1, x=x*x%mod) if(k%2==1) ans=x*ans%mod;
return ans;
}
public static void main(St... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 85390ca55f60ce1d71b0e1262f1400fa | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main {
public static int mod=1000000007, NN=1000010;
public static long pow(int k) {
long ans=1, x=26;
for(; k>0; k>>=1, x=x*x%mod) if(k%2==1) ans=x*ans%mod;
return ans;
}
public static int min( int... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 22f2ce3c8c889c05b8940e553ebb58c8 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main {
public static int mod=1000000007, NN=1000010;
public static long pow(int k) {
long ans=1, x=26;
for(; k>0; k>>=1, x=x*x%mod) if(k%2==1) ans=x*ans%mod;
return ans;
}
public static int min( int... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | f1ff278bb4824b23deaf9a9dbf6e9fd5 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main {
public static int mod=1000000007, NN=1000010;
public static long pow(int k) {
long ans=1, x=26;
for(; k>0; k>>=1, x=x*x%mod) if(k%2==1) ans=x*ans%mod;
return ans;
}
public static int min( int... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | a86af4d0b966fbfa981974300f0840d5 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main {
public static int mod=1000000007, NN=1000010;
public static long pow(int k) {
long ans=1, x=26;
for(; k>0; k>>=1, x=x*x%mod) if(k%2==1) ans=x*ans%mod;
return ans;
}
public static int min( int... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 7bb492bd68158973f7c931985bf1cfad | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main {
public static int mod=1000000007, NN=1000010;
public static long pow(int k) {
long ans=1, x=26;
for(; k>0; k>>=1, x=x*x%mod) if(k%2==1) ans=x*ans%mod;
return ans;
}
public static void main(St... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 0151b6465c6907a202d3baa3e5cc6d4d | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main {
public static int mod=1000000007, NN=1000010;
public static long pow(int k) {
long ans=1, x=26;
for(; k>0; k>>=1, x=x*x%mod) if(k%2==1) ans=x*ans%mod;
return ans;
}
public static void main(St... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 4599218924336735202701853b1c201e | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main {
public static int mod=1000000007, NN=1000010;
public static long pow(int k) {
long ans=1, x=26;
for(; k>0; k>>=1, x=x*x%mod) if(k%2==1) ans=x*ans%mod;
return ans;
}
public static void main(St... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | d265be0c3e3ef9ef341cf09ff72be2ee | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.math.*;
public class Main {
public static int mod=1000000007, NN=1000010;
public static long pow(int k) {
long ans=1, x=26;
for(; k>0; k>>=1, x=x*x%mod) if(k%2==1) ans=x*ans%mod;
return ans;
}
public static int min( int... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 7aeb79e51e0851e540c6bef2cd419733 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
static char P[];
static int b[], m;
public static void kmpPreProcess()
{
m = P.length;
b = new in... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | a8fd010bb0f2db2bfa5895204b2f2c08 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
static char P[];
static int b[], m;
public static void kmpPreProcess()
{
m = P.length;
b = new in... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | ca3169f59f0cb11d0670672f40d827a6 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.StringTokenizer;
// Codeforces Round #299 (Div. 2)
// Tavas and Malekas
public class Problem_535_D {
... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | dd06b8687bf121743c4a0e7f42003343 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static int[] zAlgo(char[] s) {
int n = s.length;
int[] z = new int[n];
for (int i = 1, l = 0, r = 0; i < n; ++i) {
if (i <= r)
z[i] = Math.min(r - i + 1, z[i - l]);
while (i + z[i] < n && s[z[i]] == s[i + z[i]])
++z[i];
if (i + z[i] - 1... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 02be6339604a72f9c89b91559044d016 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class TavasAndMalekas {
/**
* @param args
* @throws IOException
*/
public static int[] Zfunction(String s) {
int[] z = new int[s.length()];
for (in... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | a7923fa2cf2efcd2ff8ca31e6622da15 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.*;
public class Solution{
public void run() throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
String [] nm = br.readLine().trim().split(" ");
int n = Integer.parseInt(nm[0]);
in... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 256e15664cb9f29efaca2fd843e35d9e | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.zip.Adler32;
public class Contest1 {
static int mod= (int)1e9+9,base=31;
static long[]pow;
static long[]hash;
static void pre(char[]s){
pow= new long[s.length+1];
pow[0]=1;
hash= new long[s.length];
for (int i =1;i<s... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | e9de2bd477fdcf8ab1cc7b1cc2494004 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.math.*;
import java.io.*;
public class CF535D {
long exp(long b, long e) {
if(e == 0)
return 1;
if(e % 2 == 0) {
long tmp = exp(b, e / 2);
return (tmp * tmp) % MOD;
} else {
return (b * exp(b, e - 1)) % MOD;
}
}
int[] zValues(char[] s) {
int n = s.length, L = 0... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 4f94d3d949c5f64fa0acc12875fbdb77 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.util.*;
import java.io.*;
public class D535 {
public static void main(String[] args) throws IOException
{
input.init(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = input.nextInt(), k = input.nextInt();
String s = input.next();
int m = s.length();
int[] zs = zs(s.t... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 0f92a404db23085434bc3645fa41e804 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.*;
import java.util.*;
public class d1 {
static long[] h, p;
static long mod = 1000000009;
static long hash(int l, int r){
if (l == 0){
return h[r];
}
else{
return (long)((h[r] + mod - ((1l * h[l - 1] * p[r - l + 1]) % mod)) % mod);
}
}
public static void main(String[] args) thr... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | b44af019da7a88cafbc3e0e989df1cb6 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class D {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int n = sc.nextInt();
int m = sc.nextInt();
String s = sc.next();
genPow();... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | b4e252ceb61edff95fd8aa98f7c25532 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes |
import java.util.*;
import java.lang.*;
import java.io.*;
public class Temp {
static int imax = Integer.MAX_VALUE, imin = Integer.MIN_VALUE;
static long lmax = Long.MAX_VALUE, lmin = Long.MIN_VALUE;
static long mod = (long) 1e9 + 7;
public static void main(String[] args) throws java.lang.Exception {
InputReade... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | f25fc82d97494d83f1e55429c5c11451 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.HashSet;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.I... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 42f65716e2fb399981698fb35138883e | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.HashSet;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.I... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 53f485835c01fec13afad45059995f76 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.HashSet;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
imp... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | ec1d600d87daf5dbb6ccf8d10652cfb7 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.HashSet;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.I... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | faeb71abd0559940d0bd0f451a534c95 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.HashSet;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.I... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 63a951c8f89d65863e3aeb881edbcdb6 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.HashSet;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.I... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | b7b4b16609fae5dda4aaad119a7b7bc7 | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.HashSet;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.I... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | 1794c1dc10a39b172817ef76b7396f9d | train_003.jsonl | 1429029300 | Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.zip.ZipEntry;
import java.math.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
Input in = new Input(inputStream);
PrintWriter out = new... | Java | ["6 2\nioi\n1 3", "5 2\nioi\n1 2"] | 2 seconds | ["26", "0"] | NoteIn the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.Here |x| denotes the length of string x.Please note that it's possible that there is no such string (answer is 0). | Java 8 | standard input | [
"hashing",
"string suffix structures",
"greedy",
"strings"
] | 9cd17c2617b6cde593ef12b2a0a807fb | The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1). The second line contains string p (1 ≤ |p| ≤ n). The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... <... | 1,900 | In a single line print the answer modulo 1000 000 007. | standard output | |
PASSED | c82b4c76dfe575656863ecfe0f7a06da | train_003.jsonl | 1589707200 | Polycarp plays a computer game. In this game, the players summon armies of magical minions, which then fight each other.Polycarp can summon $$$n$$$ different minions. The initial power level of the $$$i$$$-th minion is $$$a_i$$$, and when it is summoned, all previously summoned minions' power levels are increased by $$... | 512 megabytes | import java.util.*;
import java.io.*;
public class SummoningMinions {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int t = Integer.parseInt(br.read... | Java | ["3\n5 2\n5 3\n7 0\n5 0\n4 0\n10 0\n2 1\n10 100\n50 10\n5 5\n1 5\n2 4\n3 3\n4 2\n5 1"] | 6 seconds | ["4\n2 1 -1 5\n1\n2\n5\n5 4 3 2 1"] | NoteConsider the example test.In the first test case, Polycarp can summon the minion $$$2$$$ with power level $$$7$$$, then summon the minion $$$1$$$, which will increase the power level of the previous minion by $$$3$$$, then destroy the minion $$$1$$$, and finally, summon the minion $$$5$$$. After this, Polycarp will... | Java 11 | standard input | [
"dp",
"greedy",
"constructive algorithms",
"flows",
"graph matchings",
"sortings"
] | e764c6437ce11b6b0cee015bc8b8e0b5 | The first line contains one integer $$$T$$$ ($$$1 \le T \le 75$$$) — the number of test cases. Each test case begins with a line containing two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 75$$$) — the number of minions availible for summoning, and the maximum number of minions that can be controlled by Polycarp,... | 2,500 | For each test case print the optimal sequence of actions as follows: Firstly, print $$$m$$$ — the number of actions which Polycarp has to perform ($$$0 \le m \le 2n$$$). Then print $$$m$$$ integers $$$o_1$$$, $$$o_2$$$, ..., $$$o_m$$$, where $$$o_i$$$ denotes the $$$i$$$-th action as follows: if the $$$i$$$-th action i... | standard output | |
PASSED | c7b264e2c1dac74a59ab5ee931014ed4 | train_003.jsonl | 1589707200 | Polycarp plays a computer game. In this game, the players summon armies of magical minions, which then fight each other.Polycarp can summon $$$n$$$ different minions. The initial power level of the $$$i$$$-th minion is $$$a_i$$$, and when it is summoned, all previously summoned minions' power levels are increased by $$... | 512 megabytes | import java.io.*;
import java.util.*;
public class gym{
static int n,k;
static int[][]in;
static long[][]memo;
static long inf=(long)1e12;
static long dp(int i,int takenInFirstK){
if(takenInFirstK>k)return -inf;
if(i>=n)return (takenInFirstK==k)?0:-inf;
if(memo[i][takenInFirstK]!=-1)return memo[i][takenIn... | Java | ["3\n5 2\n5 3\n7 0\n5 0\n4 0\n10 0\n2 1\n10 100\n50 10\n5 5\n1 5\n2 4\n3 3\n4 2\n5 1"] | 6 seconds | ["4\n2 1 -1 5\n1\n2\n5\n5 4 3 2 1"] | NoteConsider the example test.In the first test case, Polycarp can summon the minion $$$2$$$ with power level $$$7$$$, then summon the minion $$$1$$$, which will increase the power level of the previous minion by $$$3$$$, then destroy the minion $$$1$$$, and finally, summon the minion $$$5$$$. After this, Polycarp will... | Java 11 | standard input | [
"dp",
"greedy",
"constructive algorithms",
"flows",
"graph matchings",
"sortings"
] | e764c6437ce11b6b0cee015bc8b8e0b5 | The first line contains one integer $$$T$$$ ($$$1 \le T \le 75$$$) — the number of test cases. Each test case begins with a line containing two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 75$$$) — the number of minions availible for summoning, and the maximum number of minions that can be controlled by Polycarp,... | 2,500 | For each test case print the optimal sequence of actions as follows: Firstly, print $$$m$$$ — the number of actions which Polycarp has to perform ($$$0 \le m \le 2n$$$). Then print $$$m$$$ integers $$$o_1$$$, $$$o_2$$$, ..., $$$o_m$$$, where $$$o_i$$$ denotes the $$$i$$$-th action as follows: if the $$$i$$$-th action i... | standard output | |
PASSED | 824415a8cd21e69a47eca3fe81caf7f1 | train_003.jsonl | 1589707200 | Polycarp plays a computer game. In this game, the players summon armies of magical minions, which then fight each other.Polycarp can summon $$$n$$$ different minions. The initial power level of the $$$i$$$-th minion is $$$a_i$$$, and when it is summoned, all previously summoned minions' power levels are increased by $$... | 512 megabytes | import java.io.*;
import java.util.*;
public class gym{
static class Edge {
int to, f, cap, cost, rev;
Edge(int to, int cap, int cost, int rev) {
this.to = to;
this.cap = cap;
this.cost = cost;
this.rev = rev;
}
}
public static void addEdge(List<Edge>[] graph, int s, ... | Java | ["3\n5 2\n5 3\n7 0\n5 0\n4 0\n10 0\n2 1\n10 100\n50 10\n5 5\n1 5\n2 4\n3 3\n4 2\n5 1"] | 6 seconds | ["4\n2 1 -1 5\n1\n2\n5\n5 4 3 2 1"] | NoteConsider the example test.In the first test case, Polycarp can summon the minion $$$2$$$ with power level $$$7$$$, then summon the minion $$$1$$$, which will increase the power level of the previous minion by $$$3$$$, then destroy the minion $$$1$$$, and finally, summon the minion $$$5$$$. After this, Polycarp will... | Java 11 | standard input | [
"dp",
"greedy",
"constructive algorithms",
"flows",
"graph matchings",
"sortings"
] | e764c6437ce11b6b0cee015bc8b8e0b5 | The first line contains one integer $$$T$$$ ($$$1 \le T \le 75$$$) — the number of test cases. Each test case begins with a line containing two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 75$$$) — the number of minions availible for summoning, and the maximum number of minions that can be controlled by Polycarp,... | 2,500 | For each test case print the optimal sequence of actions as follows: Firstly, print $$$m$$$ — the number of actions which Polycarp has to perform ($$$0 \le m \le 2n$$$). Then print $$$m$$$ integers $$$o_1$$$, $$$o_2$$$, ..., $$$o_m$$$, where $$$o_i$$$ denotes the $$$i$$$-th action as follows: if the $$$i$$$-th action i... | standard output | |
PASSED | 5b775ebaac46115b56c4b38d215a60f3 | train_003.jsonl | 1589707200 | Polycarp plays a computer game. In this game, the players summon armies of magical minions, which then fight each other.Polycarp can summon $$$n$$$ different minions. The initial power level of the $$$i$$$-th minion is $$$a_i$$$, and when it is summoned, all previously summoned minions' power levels are increased by $$... | 512 megabytes | /**
* @author egaeus
* @mail sebegaeusprogram@gmail.com
* @veredict
* @url
* @category
* @date
**/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static java.lang.Integer.parseInt;
public class ... | Java | ["3\n5 2\n5 3\n7 0\n5 0\n4 0\n10 0\n2 1\n10 100\n50 10\n5 5\n1 5\n2 4\n3 3\n4 2\n5 1"] | 6 seconds | ["4\n2 1 -1 5\n1\n2\n5\n5 4 3 2 1"] | NoteConsider the example test.In the first test case, Polycarp can summon the minion $$$2$$$ with power level $$$7$$$, then summon the minion $$$1$$$, which will increase the power level of the previous minion by $$$3$$$, then destroy the minion $$$1$$$, and finally, summon the minion $$$5$$$. After this, Polycarp will... | Java 11 | standard input | [
"dp",
"greedy",
"constructive algorithms",
"flows",
"graph matchings",
"sortings"
] | e764c6437ce11b6b0cee015bc8b8e0b5 | The first line contains one integer $$$T$$$ ($$$1 \le T \le 75$$$) — the number of test cases. Each test case begins with a line containing two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 75$$$) — the number of minions availible for summoning, and the maximum number of minions that can be controlled by Polycarp,... | 2,500 | For each test case print the optimal sequence of actions as follows: Firstly, print $$$m$$$ — the number of actions which Polycarp has to perform ($$$0 \le m \le 2n$$$). Then print $$$m$$$ integers $$$o_1$$$, $$$o_2$$$, ..., $$$o_m$$$, where $$$o_i$$$ denotes the $$$i$$$-th action as follows: if the $$$i$$$-th action i... | standard output | |
PASSED | 501a487edc57c4886e34897ca95e4f31 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.lang.*;
import java.rmi.*;
import java.security.*;
import java.util.*;
import java.math.*;
public class D {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer tok;
static boolean hasNext() {
while (tok == null || !... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 494c56fc3be03b45d299bb932958db9e | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.lang.*;
import java.rmi.*;
import java.security.*;
import java.util.*;
import java.math.*;
public class Main {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer tok;
static boolean hasNext() {
while (tok == null |... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | c8ad02e31f184a2bb13cd58ff0fb2705 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
// written by luchy0120
public class Main {
public static void main(String[] args) throws Exception {
new Main().run();
}
class Pair{
int x;int y;
Pair(int x,int y){this.x = x;this.y = y;}
@Override
... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | ed67be6e612a2502feb8d80a429cc038 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
// written by luchy0120
public class Main {
public static void main(String[] args) throws Exception {
new Main().run();
}
class Pair{
int x;int y;
Pair(int x,int y){this.x = x;this.y = y;}
@Override
... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 5309777ceca7bfdbb24cc2fe6b1bbe78 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution{
public static Integer INT(String s) {
return Integer.parseInt(s);
}
public static Long LONG(String s) {
return Long.parseLong(s);
}
static int mod=1_000_000_007, oo=Integer.MAX_VALUE, _oo=Integer.MAX_VALUE;
//====================================... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | b67120c8f3ad3ac33c61f8f7bb6f81cf | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.util.*;
import java.io.*;
import java.text.*;
public class D1245 {
static int[] x, y, c, k;
static int n;
static ArrayList<Edge> ans;
static ArrayList<Edge> edgeList;
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWri... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 1976f474cd682883a270946f1fffb336 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import javafx.util.Pair;
import java.awt.image.AreaAveragingScaleFilter;
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
City[] cities = new City[n];
for(int i = 0; i < n; i++){
... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 5edb10461464dc2838842388ce3366b7 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes |
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.ArrayList;
public class Main {
static StringBuffer strbf = new StringBuffer();
public static void main(String[] args) throws IOException {
BufferedReader reader = new Buffe... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 94f17a4066875ae348817547ace234c6 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
private static void execute(ContestReader reader, PrintWriter out) {
int n = reader.nextInt();
int[][] xys = reader.nextIntMatrix(n, 2);
int[] cs = reader.nextIntArray(n);
int[] ks = reader.nextIntArray(n);
for (String line : new Solver(n,... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 88e3afe7f12a7b03f16732de0ee7bb7b | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 01cc3aff806d0d5b3d028dfa9c394c57 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main implements Runnable {
boolean judge = false;
FastReader scn;
PrintWriter out;
String INPUT = "";
class edge {
int u, v;
long w;
boolean taken;
edge(int a, int b, long c){
u = a;
v = b;
w = c;
taken = false;
}
}
void solve() {
int... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 0ce956d055fc594aa83ff5ed90acda04 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main implements Runnable {
boolean judge = false;
FastReader scn;
PrintWriter out;
String INPUT = "";
class edge {
int u, v;
long w;
boolean taken;
edge(int a, int b, long c){
u = a;
v = b;
w = c;
taken = false;
}
}
void solve() {
int... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 35583eb65ec59d5eb1656d598f65d73e | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main implements Runnable {
boolean judge = false;
FastReader scn;
PrintWriter out;
String INPUT = "";
class edge {
int u, v;
long w;
boolean taken;
edge(int a, int b, long c){
u = a;
v = b;
w = c;
taken = false;
}
}
void solve() {
int... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 1cca422de56f3cc80c0e392c811f29ef | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | // package Div2_597;
import javafx.util.Pair;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class Shikuji {
public static void main(String[] args)throws IOException {
B... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 73b6c13c53675c7f02f84939614719e5 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.util.*;
public class E {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner();
PrintWriter out = new PrintWriter(System.out);
int n = sc.nextInt(), x[] = new int[n], y[] = new int[n], c[] = new int[n], k[] = new int[n];
DSU dsu = new DSU(2 * n);... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | ad67cfa5261784f6ab2eca08421fcaf6 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.util.*;
import java.io.*;
public class HelloWorld{
static class Pair implements Comparable<Pair>{
int index1, index2;
long dist;
Pair(int i1, int i2, long d){
index1 = i1;
index2 = i2;
dist = d;
}
public i... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | c682b5ddbafb1c2efc011ae92869b428 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.util.*;
import java.io.*;
public class D {
static class Edge {
int source;
int destination;
long weight;
public Edge(int source, int destination, long weight) {
this.source = source;
this.destination = destination;
this.weight = weigh... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 3fc64abb7547d1a2f93b99a52b53920b | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;
import java.io.*;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 6012af08a4cbef47e62dd32622af2f38 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | /**
* BaZ :D
*/
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main
{
static MyScanner scan;
static PrintWriter pw;
static long MOD = 1_000_000_007;
static long INF = 1_000_000_000_000_000_000L;
static long inf = 2_000_000_000;
... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | c71c0c14f0771b73af5275726920bfa3 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
static int inf = (int) 1e9 + 7;
static int n, x[], y[], c[], k[], id[];
static boolean used[];
static void scan() throws IOException {
n = sc.nextInt();
x = new int [n];
y = new int [n];
... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 4ddb9f80ba52c44daea13a0dc092f7c2 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.io.UncheckedIOException;
import java.util.List;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | b5dd82fece65d09a8abfeb1b42e43391 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | // package Div2_597;
import javafx.util.Pair;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class Shikuji {
public static void main(String[] args)throws IOException {
B... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 3de302ca97ad056b53aab4d323ae0a58 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes |
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
//import java.math.*;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
static int MD= 1000000007;
... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | cc9f238a06c9bcdff18a10728d9edae6 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.util.*;
public class D
{
static class DisjointSet {
int[] s;
public DisjointSet(int n) {
Arrays.fill(s = new int[n], -1);
}
public int find(int i) {
return s[i] < 0 ? i : (s[i] = find(s[i]));
}
public boolean union(int a, int b) {
if ((a = find(a)) == (b = fin... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 8501a8e68d99ddc858a7ea63e5ecb827 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes |
/**
* Date: 09 Nov, 2019
* Link: https://codeforces.com/contest/1245/problem/D
*
* @author Prasad Chaudhari
* @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/
* @git: https://github.com/Prasad-Chaudhari
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 130876c0e53c7deadf1ac3196dd64cc9 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
public class Main {
static class UnionFind {
List<I... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 6fe71c3778fa03a94740c3f838acbd3c | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Sol4{
static class edge implements Comparable<edge>{
private int v;
private long w;
public edge(int v, long w) {
this.v = v;
this.w = w;
}
public int compareTo(edge edge) {
Long a = this.w;
Long b = edge.w;
return a.compareTo(b);
}
}
stati... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | ea4eaef3866d26775a718e93cddff005 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | //package codeforces.round597div2;
import java.io.*;
import java.util.*;
public class PowerGrid {
public static void main(String[] args) {
// try {
// FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
// PrintWriter out = new PrintWriter(new FileOutputStream("src/... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 406b4673e07084522e8bd036ee02eee6 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | //package codeforces.round597div2;
import java.io.*;
import java.util.*;
public class PowerGrid {
public static void main(String[] args) {
// try {
// FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
// PrintWriter out = new PrintWriter(new FileOutputStream("src/... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 844b50b43bcea4eb676aa85e5c588938 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | //package codeforces.round597div2;
import java.io.*;
import java.util.*;
public class PowerGrid {
public static void main(String[] args) {
// try {
// FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
// PrintWriter out = new PrintWriter(new FileOutputStream("src/... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 90a200fbb4be4e4e22c9371ff54d2721 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.AbstractCollection;
import ja... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | bec20bdea1461f3388f889b988346110 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 0c1565e475dfb1707a44e99b0c17f15d | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.util.*;
import java.io.*;
public class MainClass
{
public static void main(String[] args)throws IOException
{
Reader in = new Reader();
StringBuilder stringBuilder = new StringBuilder();
int n = in.nextInt();
long[] X = new long[n];
long[] Y = new long[n];
... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 00757b876d983ad88f542630d146af08 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes |
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
public class ShichikujiAnd... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 29d2286a140ef123e381180a5f9282dd | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/*
Prim's Algo for MST in Dense Graph O(n^2)
1.
2.
note: mst is only for undirected graphs
*/
public class Abc {
public static void main(String[] args) throws IOException {
Fas... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | dddf47d46656ae708514eed12263b3f6 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;
public class Abc {
public static void main(String[] args) throws IOException {
FastReader sc = new FastReader();
int n=sc.nextInt();
Po... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 1507f07bd7124229fe81f1c150aca27f | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;
public class Abc {
public static void main(String[] args) throws IOException {
FastReader sc = new FastReader();
int n=sc.nextInt();
Poi... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | a6e127925c2b71d17b066d690290b91d | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.awt.Point;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | bc26bbb31ec4aba20e253d675203c5af | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | /*Author: Satyajeet Singh, Delhi Technological University*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.*;
public class Main{
/*********************************************Constants******************************************/
static PrintWriter ... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 1571bf02c2ef6078ae462c3cf144a7d6 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.*;
import java.util.*;
public class Solution{
FastScanner in = null;
PrintWriter out = null;
public Solution(){
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
in = new FastScanne... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 1e3c6745513437667e9071b57fdfd850 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.*;
import java.util.*;
public class Solution{
FastScanner in = null;
PrintWriter out = null;
public Solution(){
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
in = new FastScanne... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | e99fc767457294dc03024749f4d3dd57 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.*;
import java.util.*;
public class Solution{
FastScanner in = null;
PrintWriter out = null;
public Solution(){
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
in = new FastScanne... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 1cb188872bef94c744b3d087cc02ef44 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 2d0a0536b4ad46b454fc0988dd280c3c | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
import java.awt.Point;
public class Main {
//static final long MOD = 998244353;
static final long MOD = 1000000007;
static final int INF = 1000000007;
public static void main(String[] args) {
FastScanner sc = new FastScanner();
int N = sc.ni();
lo... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 587ee016ec5e1fe50614cb86c02d091a | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 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 | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 738fcf81901d7cea8b738764f3bb6b56 | train_003.jsonl | 1572618900 | Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:There are $$$n$$$ new cities located in Prefecture X. Cities are numbered from $$$1$$$ to $$$n$$$. City $$$i$$$ is located $$$x_i$$$ km North of the shrine and $$$y_i$$$ km East of the shrine. It is possible that $$$(x_i, ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.PriorityQueue;
import java.util.Comparator;
import java.util.ArrayList;
import java.io.InputStream;
/**
* @author khok... | Java | ["3\n2 3\n1 1\n3 2\n3 2 3\n3 2 3", "3\n2 1\n1 2\n3 3\n23 2 23\n3 2 3"] | 2 seconds | ["8\n3\n1 2 3 \n0", "27\n1\n2 \n2\n1 2\n2 3"] | NoteFor the answers given in the samples, refer to the following diagrams (cities with power stations are colored green, other cities are colored blue, and wires are colored red):For the first example, the cost of building power stations in all cities is $$$3 + 2 + 3 = 8$$$. It can be shown that no configuration costs ... | Java 8 | standard input | [
"greedy",
"graphs",
"shortest paths",
"dsu",
"trees"
] | 4750f5a5aaa1ef727ebf2376641bd8ed | First line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of cities. Then, $$$n$$$ lines follow. The $$$i$$$-th line contains two space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^6$$$) and $$$y_i$$$ ($$$1 \leq y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th city. The n... | 1,900 | In the first line print a single integer, denoting the minimum amount of yen needed. Then, print an integer $$$v$$$ — the number of power stations to be built. Next, print $$$v$$$ space-separated integers, denoting the indices of cities in which a power station will be built. Each number should be from $$$1$$$ to $$$n$... | standard output | |
PASSED | 6c487c74187b26fd1f6e917afbfb1d35 | train_003.jsonl | 1426946400 | Polycarpus has a finite sequence of opening and closing brackets. In order not to fall asleep in a lecture, Polycarpus is having fun with his sequence. He is able to perform two operations: adding any bracket in any position (in the beginning, the end, or between any two existing brackets); cyclic shift — moving the ... | 256 megabytes | import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.Arrays;
import java.io.InputStream;
import java.io.Ou... | Java | ["()(())", "()("] | 5 seconds | ["(())()", "(())"] | NoteThe sequence in the first example is already correct, but to get the lexicographically minimum answer, you need to perform four cyclic shift operations. In the second example you need to add a closing parenthesis between the second and third brackets and make a cyclic shift. You can first make the shift, and then a... | Java 8 | standard input | [
"hashing",
"greedy",
"string suffix structures",
"data structures",
"strings"
] | 2e797c90135a0140102d0786f839eec4 | The first line contains Polycarpus's sequence consisting of characters "(" and ")". The length of a line is from 1 to 1 000 000. | 2,700 | Print a correct bracket sequence of the minimum length that Polycarpus can obtain by his operations. If there are multiple such sequences, print the lexicographically minimum one. | standard output | |
PASSED | 698e1be5f75383c56b4e1eed28f557f1 | train_003.jsonl | 1426946400 | Polycarpus has a finite sequence of opening and closing brackets. In order not to fall asleep in a lecture, Polycarpus is having fun with his sequence. He is able to perform two operations: adding any bracket in any position (in the beginning, the end, or between any two existing brackets); cyclic shift — moving the ... | 256 megabytes | import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public cla... | Java | ["()(())", "()("] | 5 seconds | ["(())()", "(())"] | NoteThe sequence in the first example is already correct, but to get the lexicographically minimum answer, you need to perform four cyclic shift operations. In the second example you need to add a closing parenthesis between the second and third brackets and make a cyclic shift. You can first make the shift, and then a... | Java 8 | standard input | [
"hashing",
"greedy",
"string suffix structures",
"data structures",
"strings"
] | 2e797c90135a0140102d0786f839eec4 | The first line contains Polycarpus's sequence consisting of characters "(" and ")". The length of a line is from 1 to 1 000 000. | 2,700 | Print a correct bracket sequence of the minimum length that Polycarpus can obtain by his operations. If there are multiple such sequences, print the lexicographically minimum one. | standard output | |
PASSED | 8b025f6d70b5a4edf9021f4995dae64f | train_003.jsonl | 1426946400 | Polycarpus has a finite sequence of opening and closing brackets. In order not to fall asleep in a lecture, Polycarpus is having fun with his sequence. He is able to perform two operations: adding any bracket in any position (in the beginning, the end, or between any two existing brackets); cyclic shift — moving the ... | 256 megabytes | import java.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.List;
import java.math.BigInteger;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Comparator;
import java.io.IOException;
import j... | Java | ["()(())", "()("] | 5 seconds | ["(())()", "(())"] | NoteThe sequence in the first example is already correct, but to get the lexicographically minimum answer, you need to perform four cyclic shift operations. In the second example you need to add a closing parenthesis between the second and third brackets and make a cyclic shift. You can first make the shift, and then a... | Java 8 | standard input | [
"hashing",
"greedy",
"string suffix structures",
"data structures",
"strings"
] | 2e797c90135a0140102d0786f839eec4 | The first line contains Polycarpus's sequence consisting of characters "(" and ")". The length of a line is from 1 to 1 000 000. | 2,700 | Print a correct bracket sequence of the minimum length that Polycarpus can obtain by his operations. If there are multiple such sequences, print the lexicographically minimum one. | standard output | |
PASSED | fc9721e4ce3f9ee88278576f521c4886 | train_003.jsonl | 1426946400 | Polycarpus has a finite sequence of opening and closing brackets. In order not to fall asleep in a lecture, Polycarpus is having fun with his sequence. He is able to perform two operations: adding any bracket in any position (in the beginning, the end, or between any two existing brackets); cyclic shift — moving the ... | 256 megabytes | import java.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.List;
import java.math.BigInteger;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Comparator;
import java.io.IOException;
import j... | Java | ["()(())", "()("] | 5 seconds | ["(())()", "(())"] | NoteThe sequence in the first example is already correct, but to get the lexicographically minimum answer, you need to perform four cyclic shift operations. In the second example you need to add a closing parenthesis between the second and third brackets and make a cyclic shift. You can first make the shift, and then a... | Java 8 | standard input | [
"hashing",
"greedy",
"string suffix structures",
"data structures",
"strings"
] | 2e797c90135a0140102d0786f839eec4 | The first line contains Polycarpus's sequence consisting of characters "(" and ")". The length of a line is from 1 to 1 000 000. | 2,700 | Print a correct bracket sequence of the minimum length that Polycarpus can obtain by his operations. If there are multiple such sequences, print the lexicographically minimum one. | standard output | |
PASSED | 18f35e502dd90ac12e357b7bfd2eccd0 | train_003.jsonl | 1426946400 | Polycarpus has a finite sequence of opening and closing brackets. In order not to fall asleep in a lecture, Polycarpus is having fun with his sequence. He is able to perform two operations: adding any bracket in any position (in the beginning, the end, or between any two existing brackets); cyclic shift — moving the ... | 256 megabytes | import java.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.List;
import java.math.BigInteger;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Comparator;
import java.io.IOException;
import j... | Java | ["()(())", "()("] | 5 seconds | ["(())()", "(())"] | NoteThe sequence in the first example is already correct, but to get the lexicographically minimum answer, you need to perform four cyclic shift operations. In the second example you need to add a closing parenthesis between the second and third brackets and make a cyclic shift. You can first make the shift, and then a... | Java 8 | standard input | [
"hashing",
"greedy",
"string suffix structures",
"data structures",
"strings"
] | 2e797c90135a0140102d0786f839eec4 | The first line contains Polycarpus's sequence consisting of characters "(" and ")". The length of a line is from 1 to 1 000 000. | 2,700 | Print a correct bracket sequence of the minimum length that Polycarpus can obtain by his operations. If there are multiple such sequences, print the lexicographically minimum one. | standard output | |
PASSED | 591d2e97e3e4176d9ac016125bd28a5d | train_003.jsonl | 1426946400 | Polycarpus has a finite sequence of opening and closing brackets. In order not to fall asleep in a lecture, Polycarpus is having fun with his sequence. He is able to perform two operations: adding any bracket in any position (in the beginning, the end, or between any two existing brackets); cyclic shift — moving the ... | 256 megabytes | import java.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.List;
import java.math.BigInteger;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Comparator;
import java.io.IOException;
import j... | Java | ["()(())", "()("] | 5 seconds | ["(())()", "(())"] | NoteThe sequence in the first example is already correct, but to get the lexicographically minimum answer, you need to perform four cyclic shift operations. In the second example you need to add a closing parenthesis between the second and third brackets and make a cyclic shift. You can first make the shift, and then a... | Java 8 | standard input | [
"hashing",
"greedy",
"string suffix structures",
"data structures",
"strings"
] | 2e797c90135a0140102d0786f839eec4 | The first line contains Polycarpus's sequence consisting of characters "(" and ")". The length of a line is from 1 to 1 000 000. | 2,700 | Print a correct bracket sequence of the minimum length that Polycarpus can obtain by his operations. If there are multiple such sequences, print the lexicographically minimum one. | standard output | |
PASSED | 230f989224b6aec377dbb9b4dc4bfc51 | train_003.jsonl | 1394033400 | Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to n from top to bottom and the columns — from 1 to m, from left to right. We'll represent the cell on the intersection of the i-th row and j-th column as (i, j).... | 256 megabytes | import java.io.*;
import java.util.*;
public class CodeForces {
public void solve() throws IOException {
long n,m;
long nn = nextInt();
long mm = nextInt();
long x = nextInt() % 4;
long y = nextInt() % 2;
long z = (4 - nextInt() % 4) % 4;
int p = nextInt();
long c;
for (int i = 0; i < p; i++) {
... | Java | ["3 3 3 1 1 9\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3"] | 2 seconds | ["1 3\n1 2\n1 1\n2 3\n2 2\n2 1\n3 3\n3 2\n3 1"] | NoteJust for clarity. Horizontal rotating is like a mirroring of the matrix. For matrix:QWER REWQ ASDF -> FDSAZXCV VCXZ | Java 6 | standard input | [
"implementation",
"math"
] | 14a56443e48c52c118788bd5c0031b0c | The first line of the input contains fix integers n, m, x, y, z, p (1 ≤ n, m ≤ 109; 0 ≤ x, y, z ≤ 109; 1 ≤ p ≤ 105). Each of the following p lines contains two integers xk, yk (1 ≤ xk ≤ n; 1 ≤ yk ≤ m) — the initial coordinates of the k-th candy. Two candies can lie on the same cell. | 1,500 | For each of the p candies, print on a single line its space-separated new coordinates. | standard output | |
PASSED | 68cd64cc31f213fb0a0d5eaa017cd398 | train_003.jsonl | 1394033400 | Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to n from top to bottom and the columns — from 1 to m, from left to right. We'll represent the cell on the intersection of the i-th row and j-th column as (i, j).... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class T400C {
public void solve(int n, int m, int x, int y, int z, int p, int[][] a) {
... | Java | ["3 3 3 1 1 9\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3"] | 2 seconds | ["1 3\n1 2\n1 1\n2 3\n2 2\n2 1\n3 3\n3 2\n3 1"] | NoteJust for clarity. Horizontal rotating is like a mirroring of the matrix. For matrix:QWER REWQ ASDF -> FDSAZXCV VCXZ | Java 6 | standard input | [
"implementation",
"math"
] | 14a56443e48c52c118788bd5c0031b0c | The first line of the input contains fix integers n, m, x, y, z, p (1 ≤ n, m ≤ 109; 0 ≤ x, y, z ≤ 109; 1 ≤ p ≤ 105). Each of the following p lines contains two integers xk, yk (1 ≤ xk ≤ n; 1 ≤ yk ≤ m) — the initial coordinates of the k-th candy. Two candies can lie on the same cell. | 1,500 | For each of the p candies, print on a single line its space-separated new coordinates. | standard output | |
PASSED | 80dd89d94bcc1fd130da0c0bf3bd1d40 | train_003.jsonl | 1394033400 | Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to n from top to bottom and the columns — from 1 to m, from left to right. We'll represent the cell on the intersection of the i-th row and j-th column as (i, j).... | 256 megabytes | import java.io.PrintWriter;
import java.util.Scanner;
public class B {
public static void main(String[] args){
PrintWriter pw = new PrintWriter(System.out, true);
Scanner sc = new Scanner(System.in);
long n, m, x, y, z, p, tmp;
n = sc.nextLong();
m = sc.nextLong();
x = sc.nextLong();
y = sc.nextLong();... | Java | ["3 3 3 1 1 9\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3"] | 2 seconds | ["1 3\n1 2\n1 1\n2 3\n2 2\n2 1\n3 3\n3 2\n3 1"] | NoteJust for clarity. Horizontal rotating is like a mirroring of the matrix. For matrix:QWER REWQ ASDF -> FDSAZXCV VCXZ | Java 6 | standard input | [
"implementation",
"math"
] | 14a56443e48c52c118788bd5c0031b0c | The first line of the input contains fix integers n, m, x, y, z, p (1 ≤ n, m ≤ 109; 0 ≤ x, y, z ≤ 109; 1 ≤ p ≤ 105). Each of the following p lines contains two integers xk, yk (1 ≤ xk ≤ n; 1 ≤ yk ≤ m) — the initial coordinates of the k-th candy. Two candies can lie on the same cell. | 1,500 | For each of the p candies, print on a single line its space-separated new coordinates. | standard output | |
PASSED | 1d26ca47a637477760062dda15ee6658 | train_003.jsonl | 1394033400 | Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to n from top to bottom and the columns — from 1 to m, from left to right. We'll represent the cell on the intersection of the i-th row and j-th column as (i, j).... | 256 megabytes | import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.FileInputStream;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actu... | Java | ["3 3 3 1 1 9\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3"] | 2 seconds | ["1 3\n1 2\n1 1\n2 3\n2 2\n2 1\n3 3\n3 2\n3 1"] | NoteJust for clarity. Horizontal rotating is like a mirroring of the matrix. For matrix:QWER REWQ ASDF -> FDSAZXCV VCXZ | Java 6 | standard input | [
"implementation",
"math"
] | 14a56443e48c52c118788bd5c0031b0c | The first line of the input contains fix integers n, m, x, y, z, p (1 ≤ n, m ≤ 109; 0 ≤ x, y, z ≤ 109; 1 ≤ p ≤ 105). Each of the following p lines contains two integers xk, yk (1 ≤ xk ≤ n; 1 ≤ yk ≤ m) — the initial coordinates of the k-th candy. Two candies can lie on the same cell. | 1,500 | For each of the p candies, print on a single line its space-separated new coordinates. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.