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 | 101b2edb2a9e2c2f91b8bdab6a3584e1 | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
public class CF920F {
static final boolean IS_OJ = System.getProperty("ONLINE_JUDGE") != null;
public static BlockReader input;
public static void main(String[] args) throws FileNotFoundException {
if... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | 54de9367f02872636a14094254134e27 | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class lp{
static PrintWriter out = new PrintWriter(System.out);
static void fun(int div[])
{
for(int i=1;i<div.length;i++)
for(int j=i;j<div.length;j=j+i)
div[j]++;
}
static void update(long BIT[],int i,int sum)
... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | 6061166fe432bd4b3382aaebb0825ace | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | /* Idea is that after at most 1o replace operations a number will become contstant. After that we do not need to aply replce
operations. Use dsu to find next index where we can apply replace operation.
Use BIT to update and find sum in given range
*/
import java.util.*;
import java.io.*;
import java.math.BigInteger; ... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | 2eacb8c6469cc91179db7f319e0e06e7 | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | /*
Keep solving problems.
*/
import java.util.*;
import java.io.*;
public class CFF {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
final long MOD = 1000L * 1000L * 1000L + 7;
int[] dx = {0, -1, 0, 1};
int[] dy = {1, 0, -1, 0};
private static final String yes = ... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | e6dcade4681767a370a760acac069c22 | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | 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.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | 4144259e31c4d2b128f9cd84d1cf0e6b | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | import java.util.*;
import java.io.*;
import static java.lang.System.in;
public class Main {
static int n,n0=1,m;
static int[] dat, dic,a;
static long[] sum;
// static ArrayList<Integer>[] graph,tree;
public static void main(String[] args)throws IOException {
BufferedReader reader = new Buf... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | 85e10b57872d72994fa2da5fe8379e3e | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | import java.util.*;
import java.io.*;
import static java.lang.System.in;
public class Main {
static int n,n0=2,m;
static int[] dat, dic,a;
static long[] sum;
// static ArrayList<Integer>[] graph,tree;
public static void main(String[] args)throws IOException {
BufferedReader reader = new Buf... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | 5606a96eca7be9148fcd2721509a3769 | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | import java.util.*;
import java.io.*;
import static java.lang.System.in;
public class Main {
static int n,n0=2,m;
static int[] dat, dic,a;
static long[] sum;
// static ArrayList<Integer>[] graph,tree;
public static void main(String[] args)throws IOException {
BufferedReader reader = new Buf... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | 04a7a651aa5ec48a9af71a1cfb044bac | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]) {new Main().run();}
FastReader in = new FastReader();
PrintWriter out = new PrintWriter(System.out);
void run(){
work();
out.flush();
}
long mod=998244353;
long gcd(long a,long b) {
return b==0?a:gcd(b,a%b);
... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | e9c621eafb666c841cf10b481ba0b163 | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]) {new Main().run();}
FastReader in = new FastReader();
PrintWriter out = new PrintWriter(System.out);
void run(){
work();
out.flush();
}
long mod=998244353;
long gcd(long a,long b) {
return b==0?a:gcd(b,a%b);
... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | bbf145728bf95bdf0a678b657697209c | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes |
import java.util.*;
import java.io.*;
public class F {
String INPUT = "7 6\n" +
"6 4 1 10 3 2 4\n" +
"2 1 7\n" +
"2 4 5\n" +
"1 3 5\n" +
"2 4 4\n" +
"1 5 7\n" +
"2 1 7";
int N = 1000005;
... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | 51606ac87c1b1d25e948761e717bc1a9 | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | import java.io.*;
import java.util.*;
public class F {
FastScanner in;
PrintWriter out;
boolean systemIO = true;
int[] divisors;
int INF = (int) 1e6;
int[] ones;
public void solve() throws IOException {
precalc();
int n = in.nextInt();
int m = in.nextInt();
long tr... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | d655499dd34d42909ed483e99845244e | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | import java.util.*;
import java.io.*;
public class F {
static int segmax[];
static long segsum[];
static int a[];
static int l, r;
static int D[];
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new Stri... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | f8ad89e0a01d984fd294c057b4b4ccb8 | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | import java.util.*;
public class F {
static int segmax[];
static long segsum[];
static long pfsum[];
static int a[];
static int l, r;
static int D[];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
a = new int[n+1];
for(int i=1;i<=... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | a74040b68fa7c1cd0abb6dbeedd02a67 | train_000.jsonl | 1517582100 | Let D(x) be the number of positive divisors of a positive integer x. For example, D(2)β=β2 (2 is divisible by 1 and 2), D(6)β=β4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integers. You have to process two types of queries: REPLACE l r β for every replace ai with D(ai); SUM l r β calculate . Pri... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
void solve() {
int n=ni(),m=ni();
cnt=new int[1000001];
for(int i=1;i<=1e6;i++){
for(int j=i;j<=1e6;j+=i) cnt[j]++;
}
constant=new boolean[4*n+1];
tree=new long[4*n+1];
... | Java | ["7 6\n6 4 1 10 3 2 4\n2 1 7\n2 4 5\n1 3 5\n2 4 4\n1 5 7\n2 1 7"] | 2 seconds | ["30\n13\n4\n22"] | null | Java 8 | standard input | [
"data structures",
"dsu",
"number theory",
"brute force"
] | 078cdef32cb5e60dc66c66cae3d4a57a | The first line contains two integers n and m (1ββ€βn,βmββ€β3Β·105) β the number of elements in the array and the number of queries to process, respectively. The second line contains n integers a1, a2, ..., an (1ββ€βaiββ€β106) β the elements of the array. Then m lines follow, each containing 3 integers ti, li, ri denoting i-... | 2,000 | For each SUM query print the answer to it. | standard output | |
PASSED | be917294308ea0c7c02d153f4827efc4 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 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.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStrea... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 3e92aeb44bbca56a76264db0451d1a42 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 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.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStrea... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 0208817c8d7c082f0e035c66056343c3 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | //package DP;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.awt.Point;
/**
*
* @author prabhat // use stringbuilder,TreeSet, priorityQueue, x+y=(x&y + x|y);
*/
public class dp6
{
public static int a[],n,max1=1... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 2f37dd34c38961c367d4ed06cb62eae9 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.util.*;
import java.io.*;
public class lol
{
public static char r(char a,char b,int k)
{
for(int h=0;h<k;h++)
{
if(a-'A'!=h && b-'A'!=h)
return (char)(h+'A');
}
return 'A';
}
public static int calc(int k,char[] str,int changes)
{
for(int h=0;h<str.length;h+=1)
{
if(h+2<str.length... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | d9f8e233a46dab8412db71b16fab374c | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | /**
* DA-IICT
* Author : PARTH PATEL
*/
import java.io.*;
import java.math.*;
import java.util.*;
import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;
public class C219 {
public static int mod = 1000000007;
static Fa... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 634a6bcdd4989d06fffaab9cf9807a1a | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes |
import java.io.*;
import java.util.*;
public class CF_219_C_COLOR_STRIPE {
static final int INF = (int) 1e9;
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
char[] a = sc.next().toCharArray();
int memo[][] = ne... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 6ceb92115ddd0d9222304508301bc125 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes |
import java.io.*;
import java.util.*;
public class CF_219_C_COLOR_STRIPE {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
char[] c = sc.next().toCharArray();
int ans = 0;
if (k == 2) {
char[] ab = new char[... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 25ad7fd2f637af64885ccff86dff32ca | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class CF_219_C_COLOR_STRIPE {
static int memo[][];
static int n, k;
static char[] a;
static final int INF = (int) 1e9;
static... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | e45dec65b9c183f98f6e3732f95a5f5f | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class CF_219_C_COLOR_STRIPE {
static int memo[][];
static int n, k;
static char[] a;
static final int INF = (int) 1e9;
static... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | c6c0cce7688259c8caee6561f3891661 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes |
import java.io.*;
import java.util.*;
public class CF_219_C_COLOR_STRIPE {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
char[] c = sc.next().toCharArray();
int ans = 0;
if (k == 2) {
char[] ab = new char[... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 2e649d560ed242744d8760f15e38b1be | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Col... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | cb02b39081a35bb4a35323e0484c19c9 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | c62b0d1542e2594ee0e4b4fc250cbd1c | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes |
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
public class ColorStripe
{
static int[][] memo;
static int k;
static int n;
static char[] arr;
static String[][] word;
static PrintWriter pw = new PrintWriter(System.out);
public static void main(String[] args)
{
Scanner sc = new... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | e42d6bc3ae61e02fac69f6ff6f5d5053 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
static InputReader in = new InputReader(System.in);
static PrintWriter out = new PrintWriter(System.out);
static int MOD = 1000000007;
static int M = 505;
static int oo = Integer.MAX_VALUE;
static int[] di = {-1, 1, 0, ... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | cedf8e09b96b70fc25f9dddd11de4a3d | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.util.*;
import java.io.*;
public class A
{
public static void main(String ar[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s1[]=br.readLine().split(" ");
int n=Integer.parseInt(s1[0]);
int k=In... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | ea66c815fc56300250fb770c7b32c88a | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
// atharva washimkar
// Oct 13, 2019
public class CODEFORCES_219_C {
public static void main (String[] t) throws IOException {
INPUT in = new INPUT (System.in);
PrintWriter out = new PrintWriter (... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 6e7f4f0aa28ea9ebfdaabbe3e8b76823 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.util.concurrent.*;
public class Main {
//---------------------------------------------------------------------------
static int n, k;
static char[] a;
public static void main(String[] args) throws Exception {
... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | cd755be710c0f08d0c3f0ad21261d4f1 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
/**
*
* @author Saju
*
*/
public class Main {
private static int dx[] = { 1, 0, -1, 0 };
private static int dy[] = { 0, -1, 0, 1 };
private static final long INF = Long.MAX_VALUE;
private static final int INT_INF = Integer.MAX_VALUE;
... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 63c27de718feb0d5c2ec7d4bcefc7ec5 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.util.Scanner;
public class Main {
public static int N, K;
public static String str;
public static int[] a;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
N = s.nextInt();
K = s.nextInt();
str = s.next();
a = new int[N + 1];
for (int i = 1; i <= N; i++) {
a[... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | cf96bdc5e78febb85253e1084695de2f | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | import java.util.Scanner;
public class Main {
public static int N, K;
public static String str;
public static int[] a;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
N = s.nextInt();
K = s.nextInt();
str = s.next();
a = new int[N + 1];
for (int i = 1; i <= N; i++) {
a[... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 87042fdf74e8db98cfe1ea853a4d8132 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | //package codeforces;
import java.util.Scanner;
public class ColorStripe2 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
in.nextLine();
String s = in.nextLine();
char[] cs = s.toCharArray();
int res = 0;
if (k > 2) {
for... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 285e399417c18450c05e75d75f815779 | train_000.jsonl | 1346081400 | A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells. | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
int n,k;
Scan... | Java | ["6 3\nABBACC", "3 2\nBBB"] | 2 seconds | ["2\nABCACA", "1\nBAB"] | null | Java 8 | standard input | [
"dp",
"greedy",
"brute force"
] | 0ecf60ea733eba71ef1cc1e736296d96 | The first input line contains two integers n and k (1ββ€βnββ€β5Β·105;Β 2ββ€βkββ€β26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding ce... | 1,600 | Print a single integer β the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe. | standard output | |
PASSED | 4d8a18e07c5ad48e7ef34213bcd83c33 | train_000.jsonl | 1277391600 | Everyone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held in Berland. BFA took the decision to change some World Cup regulations: the final tournament features n teams (n is always even) the first nβ/β2 teams (accordi... | 64 megabytes | import java.util.*;
public class A {
// TreeMap really not necessary since we are sorting by values. A normal hashmap would actually do.
static Map<String,Score> teams = new TreeMap<String,Score>();
static class Score {
int p; // Points
int gf; // Goals for
int ga; // Goals again... | Java | ["4\nA\nB\nC\nD\nA-B 1:1\nA-C 2:2\nA-D 1:0\nB-C 1:0\nB-D 0:3\nC-D 0:3", "2\na\nA\na-A 2:1"] | 2 seconds | ["A\nD", "a"] | null | Java 11 | standard input | [
"implementation"
] | 472c0cb256c062b9806bf93b13b453a2 | The first input line contains the only integer n (1ββ€βnββ€β50) β amount of the teams, taking part in the final tournament of World Cup. The following n lines contain the names of these teams, a name is a string of lower-case and upper-case Latin letters, its length doesn't exceed 30 characters. The following nΒ·(nβ-β1)β/... | 1,400 | Output nβ/β2 lines β names of the teams, which managed to get through to the knockout stage in lexicographical order. Output each name in a separate line. No odd characters (including spaces) are allowed. It's guaranteed that the described regulations help to order the teams without ambiguity. | standard output | |
PASSED | 0749a6afc133c918aa19cc05a9eeb7f1 | train_000.jsonl | 1277391600 | Everyone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held in Berland. BFA took the decision to change some World Cup regulations: the final tournament features n teams (n is always even) the first nβ/β2 teams (accordi... | 64 megabytes | import java.util.*;
public class WorldFootBallCup {
// TreeMap really not necessary since we are sorting by values. A normal hashmap would actually do.
static Map<String,Score> teams = new TreeMap<String,Score>();
static class Score {
int p; // Points
int gf; // Goals for
i... | Java | ["4\nA\nB\nC\nD\nA-B 1:1\nA-C 2:2\nA-D 1:0\nB-C 1:0\nB-D 0:3\nC-D 0:3", "2\na\nA\na-A 2:1"] | 2 seconds | ["A\nD", "a"] | null | Java 11 | standard input | [
"implementation"
] | 472c0cb256c062b9806bf93b13b453a2 | The first input line contains the only integer n (1ββ€βnββ€β50) β amount of the teams, taking part in the final tournament of World Cup. The following n lines contain the names of these teams, a name is a string of lower-case and upper-case Latin letters, its length doesn't exceed 30 characters. The following nΒ·(nβ-β1)β/... | 1,400 | Output nβ/β2 lines β names of the teams, which managed to get through to the knockout stage in lexicographical order. Output each name in a separate line. No odd characters (including spaces) are allowed. It's guaranteed that the described regulations help to order the teams without ambiguity. | standard output | |
PASSED | 3107fbccbdbdf007699b16d416aa7740 | train_000.jsonl | 1277391600 | Everyone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held in Berland. BFA took the decision to change some World Cup regulations: the final tournament features n teams (n is always even) the first nβ/β2 teams (accordi... | 64 megabytes | import java.io.*;
import java.util.*;
import java.util.regex.*;
public class MyClass {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
... | Java | ["4\nA\nB\nC\nD\nA-B 1:1\nA-C 2:2\nA-D 1:0\nB-C 1:0\nB-D 0:3\nC-D 0:3", "2\na\nA\na-A 2:1"] | 2 seconds | ["A\nD", "a"] | null | Java 11 | standard input | [
"implementation"
] | 472c0cb256c062b9806bf93b13b453a2 | The first input line contains the only integer n (1ββ€βnββ€β50) β amount of the teams, taking part in the final tournament of World Cup. The following n lines contain the names of these teams, a name is a string of lower-case and upper-case Latin letters, its length doesn't exceed 30 characters. The following nΒ·(nβ-β1)β/... | 1,400 | Output nβ/β2 lines β names of the teams, which managed to get through to the knockout stage in lexicographical order. Output each name in a separate line. No odd characters (including spaces) are allowed. It's guaranteed that the described regulations help to order the teams without ambiguity. | standard output | |
PASSED | 542b395c51b61298c5a52c6a41bb3de3 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
public class Main {
static PrintWriter out;
static InputReader ir;
static void solve() {
char[] s = ir.next().toCharAr... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | c286256f6c8a055b7146cd8ec0d22032 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes |
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | fbf5cce74f0a1adc1fe5fe025115e2e7 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 82b259e6742c5198fe5156d9d8cef9b3 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
char[] s = scanner.next().trim().toCharArray();
long cnt = 0;
int mini = s.length;
for (int i = s.length - 3; i >= 0; i--) {
int k ... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | ef71a1308dc0b005a8d02ff540f048b3 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;
public class CompetitiveProgramming {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
String string = scanner.nextLine();
System.out.println(new Solver().goodTriples(string)... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | d9bb6dc057d4820c086d962e40097b01 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
public static void main(String[] args) throws IOException {
PrintWriter out = new PrintWriter(System.out);
//Scanner sc = new Scanner();
Reader in = new Reader();
Main solver = new Main();
solver.... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | cb2250be361387b9b03dcc9a8f813d91 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.util.Scanner;
public class Main {
public static int N;
public static String str;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
str = s.next();
N = str.length();
long res = 0;
for (int i = 0; i < N; i++) {
for (int c = 3; c <= 9; c++) {
int j = (i + c - 1)... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 5f6f3e6ec29178238ebe188109ce0d63 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author islammohsen
*/
public class Main {
public static void main(String[] args) {
InputStre... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 4d454df7e298de1e621ed72fa2e7bd7e | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundExceptio... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 74209650b21741dbb4b73a577b743b85 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
imp... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | fc103d0ebf89a23ed31c094af51c016a | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | // https://codeforces.com/blog/entry/67189?#comment-513690
// upsolve with rainboy
import java.io.*;
public class CF1169D {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
char[] cc = br.readLine().toCharArray();
int n = cc.le... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 311a906d2fdcdce65411c1ffa36e940f | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.util.Scanner;
public class D562 {
@SuppressWarnings("resource")
public static void main(String[] args){
Scanner input = new Scanner(System.in);
char[] nums = input.next().toCharArray();
int l = nums.length;
int[] close = new int[l];
for (int i = 0; i < l; i++){
close[i] = l;
}
for (int ... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 9eb61f13a3a922dfbecb30ef1383a500 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
public class D {
public static void main(String[] args) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
HashSet<String> stringSet = new HashSet<S... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 482f7e766c2a35a2f3619656d00f7c5f | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.reflect.Array;
public class D {
static final int MOD = 1000000007; // 1e9 + 7
static final boolean AUTO_FLUSH = false; // slow if true
// int = num(); // long = ll();
// string = next(); // a string line = line();
// -------... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 014120520ffdcda107c07506e520b562 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | //JDope
import java.util.*;
import java.io.*;
import java.math.*;
public class D{
public static void main(String[] omkar) throws Exception
{
Set<Integer> a1 = new HashSet<Integer>();
a1.add(0);
a1.add(1);
Set<Integer> a2 = new HashSet<Integer>();
a2.add(0);
a2.add(1);
a2.add(2);
a2.add(3);
S... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 2c0175ecc4a87264a511ca10fb29df92 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.lang.invoke.MethodHandles;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Has... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 0d0dab6804a97a8b282b87cd71e72d39 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.lang.invoke.MethodHandles;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Has... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 3227f67175a914ffb85d562c13b1bb5a | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.lang.invoke.MethodHandles;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Has... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | c7215f921d7603d57b788f28ae595cde | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.lang.invoke.MethodHandles;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Has... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | e1789fc66e43225f10894eac62c2f227 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 4438cbdcd9a837b47a830c21916c3392 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
/**
* @author madi.sagimbekov
*/
public class C1169D {
private static ... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | 143a7fdb62d4d2bfb03d3a1fa6c0a7f2 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 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
*/
public class... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | e1a9c9372eac0289132720e5cd4d9652 | train_000.jsonl | 1558884900 | Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq... | 256 megabytes | import java.util.*;
public class triple {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
// int n=9;
// T:for(int i=0;i<1<<n;i++) {
// String x=Integer.toBinaryString(i);
// while(x.length()<n) x="0"+x;
// for(int j=0;j<n;j++) {
// for(int k=1;k<n;k++) {
// if(j+2*k>=n)... | Java | ["010101", "11001100"] | 4 seconds | ["3", "0"] | NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$. | Java 8 | standard input | [
"brute force"
] | 71bace75df1279ae55a6e755159d4191 | The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones. | 1,900 | Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$. | standard output | |
PASSED | c48c474d0d62e4d0a6bad6d85bbc5dcd | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {
File file = new File("in.txt");
InputStream inputStream = null;
// try ... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 9894081326f504f600b7ea44c16c055b | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class CF_C {
static BufferedReader in;
static PrintWriter out;
static StringTokenizer tok;
public static void main(String[] args) throws IO... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 55c3c9bce0f2d3ead24ca56d71b27655 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;
public class C{
public static void main(String args[]) {
FastScanner scan = new FastScanner();
PrintWriter out = new PrintWriter(Sys... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 033101206f98810300017043620c5ceb | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | 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.StringTokenizer;
import java.util.TreeMap;
public class Lorenzo {
static ArrayList<Tri> inc;
sta... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 9224a9ff33d41919e61583b6b256ff83 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.util.*;
import java.io.* ;
public class Main {
public static void main(String[] args) throws Exception {
// Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in), 16000));
InputStream inputStream = System.in;
OutputStream outputStream = S... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 1f3170d7c27795c2e2ccb2d2e78bb776 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes |
import java.io.*;
import java.util.*;
public class CF_676_C_Lorenzo_Von_Matterhorn {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
StringBuilder st = new StringBuilder();
int q = sc.nextInt();
Tree t = new Tree();
while(q -->0 )
if(sc.nextInt() ... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 6925e46269f1cdc27c9bf2df3f8d6ce8 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes |
import java.io.*;
import java.util.*;
/**
*
* @author Sourav Kumar Paul
*/
public class SolveC {
public static HashMap<Long,Long> map;
public static void main(String[] args) throws IOException{
Reader in = new Reader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new O... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 05cc3667a2269011cec959fd27549e58 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class ProblemC {
Map<Long, Long> road2cost = new HashMap<Long, Long>();
public static Scanner sc;
public static void main(String[] args) throws FileNotFoundException {
sc = new ... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 975aa8946c8b26e34c7975b8b6d4d83c | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | //package codeforces.contest697;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class C {
public static void main(String... args) {
FastScanner s = new FastScanner();
// for (l... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 9250356eb2b8bcbeacefe40e414a615b | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 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.StringTokenizer;
import java.util.TreeMap;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 4309d36fc776bdbbe5d15c784424c7ed | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.*;
import java.util.*;
public class Task {
public static void main(String[] args) throws IOException {
new Task().solve();
}
int mod = 1000000007;
PrintWriter out;
int n;
int m;
int inf = 2000000000;
void solve() throws IOException {
Reader in;
... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | dfffd62a3cf8739a3c8717e7ee6f6780 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.NoSuchElementException;
public class C {
int Q;
HashMap<Long,HashMap<Long,Long>> map;
public void add(long u,long v,long w){
if(u > v){
long tmp = u;
u = v;
v = tmp;
}
//u ... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 85a12f290df84f7d2fee9d59da5493e7 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
public class TestClass {
private static InputStream stream;
private static byte[] buf = new byte[1024];
private static int curChar;
private static int numChars;
private static Space... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 38960bbba53df74c150ed034c8eb51da | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Main {
static HashMap<Long... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 1be8d094d831d6b51dbecc734f14def7 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.PriorityQueue;
imp... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 896cbf27c4a00393adca7f4dcea8af5c | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 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.HashMap;
import java.util.StringTokenizer;
public class C {
static HashMap<Long, Edge> map;
public static void main(String[] args) {
InputReader in... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | e6ed510d5f27bf54c8783b2b38c04a3c | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.*;
import java.math.BigDecimal;
import java.util.*;
public class Codeforces {
static MyScanner sc = new MyScanner();
static long min (long a, long b) {
if (a>b) {
return b;
}
return a;
}
static void newrule (Map<Long,Long> map, long v, long u, long w) {
long len1 = 0; long len2 ... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 9be9115d78bc19c9efb7cd9cac1a8f37 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes |
/*
* Author- Priyam Vora
* BTech 2nd Year DAIICT
*/
import java.io.*;
import java.math.*;
import java.util.*;
import javax.print.attribute.SetOfIntegerSyntax;
public class Graph1 {
private static InputStream stream;
private stati... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 0d8201677d1a0bf37f40969581c6d9e4 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.lang.*;
import java.util.*;
public class Main {
static HashMap<Long, Node> graph = new HashMap<>();
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long q = Long.parseLong(sc.nextLine());
for(long i=0;i<q;i++){
String[] line = sc.n... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 416dc38f3d5f9d0a30afddfdd87ced8c | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | //package CF;
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.StringTokenizer;
import java.util.TreeMap;
public class A {
static int INF = (int) 1e9 + 7;
public static vo... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 7e87288202d16a6f4c0ed6cb24192b36 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | //package round362;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
long two[] = new long[100];
two[0]=1;
for(int i=1;i<100;i++)
{... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | db2f0d6defd48f6866f300eb6fa61ce9 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.TreeSet;
public class C {
private static class Task {
long[] LCA(long v, long u) {
TreeSet<Long> set = new T... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | c444e189e9c4a115ec78ed71d49ec28a | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.TreeMap;
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = ... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 2bce7869b17aed6d60fe33c0824d46c0 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes |
import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;
public class Main {
static Map<Long,Long> cost;
pu... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | adc916402f567d858bcd23b4e42031bd | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class LorenzoVonMatterhorn {
void solve() {
int q = in.nextInt();
... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | c85c55c2a2386c8e2ad343e0ae8c51f1 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
public class Main {
static HashMap<Long ,Long> weights = new HashMap();
static long findLCA(long v, long u){
int du,dv;
while(u!=v){
//System.out.println("u "+u+" v "+v);
du = (int)(Math.log(u)/Math.log(2));
dv = (int)(... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | cedd5376a34efe43533a3e93cd8d9763 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes |
/**
*
* @author meashish
*/
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 89562bedb81cb853f3112a622b558025 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | //package com.codeforces.competitions.year2016.julytoseptember.round362div2;
import java.io.*;
import java.util.*;
public final class TaskC
{
public static void main(String[] args)
{
InputReader in = new InputReader(System.in);
OutputWriter out = new OutputWriter(System.out);
Solver solver ... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | b3138b66d5d039eeffee260b5b43174f | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | //package com.codeforces.competitions.year2016.julytoseptember.round362div2;
import java.io.*;
import java.util.*;
public final class TaskC
{
public static void main(String[] args)
{
InputReader in = new InputReader(System.in);
OutputWriter out = new OutputWriter(System.out);
Solver solver ... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 72ee2530b0ba82c3d23bf275a805dc42 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | /**
* @author derrick20
*/
import java.io.*;
import java.util.*;
public class LorenzoVonMatterhorn {
public static void main(String[] args) throws Exception {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int Q = sc.nextInt();
HashMap<Long, Lo... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 5091fb082a85dbafe7ecfd7846cc56ea | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sarthak
*/
import java.util.*;
import java.math.*;
import java.io.*;
public class rnd362_C {
static class Fas... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 445bcb0762d92e65508929ac567c6a6c | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | /**
* Created by vladislav on 7/13/16.
*/
import java.util.*;
import java.math.*;
public class hell {
public static void main(String[] args){
HashMap<Long, Long> costs = new HashMap<Long, Long>();
long n, type, v, u, w;
Scanner scan = new Scanner(System.in);
n = scan.nextLong();
... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | f7a49e16af228615179d087721f7bc36 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.*;
import java.util.*;
public class Question {
static long[] visted;
static ArrayList<Integer>[] grid;
static TreeMap<Pair, Long> hm;
public static long LCAInt(long v, long u) {
long res = 0;
while (v != u) {
if (u < v) {
long newv = v / 2;
Pair p = new Pair(newv, v);
if (hm.cont... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | d1b74023c540de1506e678d4ca1fb66a | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.io.PrintWriter;
import java.util.*;
public class TaskC {
public static void main(String[] args) {
TaskC tC = new TaskC();
PrintWriter pw = new PrintWriter(System.out);
tC.solve(new Scanner(System.in), pw);
pw.close();
}
public void solve(Scanner input, PrintWriter output) {
int q... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 46fa8e38ea2d35d479102eca4a3f83ac | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes | import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.Vector;
public class RobinHood2 {
static HashMap<Long, Long> tree = new HashMap<Long, Long>();
public static void update(long u, long w, long co... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 4bfda61ce65c2734a4f7488b1d32e526 | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes |
import java.util.*;
public class Nyc {
static Long swap(Long a, Long b) {
return a;
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
HashMap<Long, Long> map = new HashMap<>();
int q = sc.nextInt();
while (q-- > 0) {
int op... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output | |
PASSED | 9b0cbe9f80cf7d1b7ff061ae3ce7035c | train_000.jsonl | 1468514100 | Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2iβ+β1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | 256 megabytes |
/**
* Created by Bakytzhan_Manaspayev on 8/2/2016.
*/
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.i... | Java | ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4"] | 1 second | ["94\n0\n32"] | NoteIn the example testcase:Here are the intersections used: Intersections on the path are 3, 1, 2 and 4. Intersections on the path are 4, 2 and 1. Intersections on the path are only 3 and 6. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals... | Java 8 | standard input | [
"data structures",
"implementation",
"trees",
"brute force"
] | 12814033bec4956e7561767a6778d77e | The first line of input contains a single integer q (1ββ€βqββ€β1β000). The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v ... | 1,500 | For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.