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 | f571402bb7ec779328eb1064676bf0f4 | train_000.jsonl | 1580826900 | You are given an array $$$a$$$ consisting of $$$n$$$ integers.In one move, you can choose two indices $$$1 \le i, j \le n$$$ such that $$$i \ne j$$$ and set $$$a_i := a_j$$$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is th... | 256 megabytes | import java.util.Scanner;
public class Sumodd{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int count1 =0;
int count2 =0;
for(int i =0;i<a;i++){
int b = in.nextInt();
int[] arr = new int[b];
for(int k = 0;k<arr.length;k++){
arr[k] = in.nextIn... | Java | ["5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1"] | 1 second | ["YES\nNO\nYES\nNO\nNO"] | null | Java 11 | standard input | [
"math"
] | 2e8f7f611ba8d417fb7d12fda22c908b | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2000$$$) β the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2000$$$) β the number of elements in $$$a$$$. The second line of the test case contains ... | 800 | For each test case, print the answer on it β "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise. | standard output | |
PASSED | 535c09a8b4e2e9a5c479b0d49ba790f4 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes |
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
public class ff {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
HashMap<Integer,Integer> mp=new HashMap<In... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | fdd4f0de54f6889c41c59b84b7564bf2 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.util.*;
public class a
{
static int mod = (int) 1e9 + 7;
static int Infinity=Integer.MAX_VALUE;
static int negInfinity=Integer.MIN_VALUE;
public static void main(String args[])
{
Scanner d= new Scanner(System.in);
int n,x,i,z;
n=d.nextInt();
x=d.nextInt();... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 5f53dab0254a466d9e0c00c7d4796b60 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.io.*;
import java.util.*;
public class CFB {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
private static final long MOD = 1000L * 1000L * 1000L + 7;
private static final int[] dx = {0, -1, 0, 1};
private static final int[] dy = {1, 0, -1, 0};
private... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 44d3edf191999f51e3524356996f493f | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | //package codeforces.Round500;
import java.util.HashMap;
import java.util.Scanner;
public class And {
private static HashMap<Integer, Boolean> visited;
private static HashMap<Integer, Boolean> visitedAnd;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n ... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 37ecae2f73bff34e7a836c687b2e3712 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.io.*;
import java.lang.*;
public class CF1013B {
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] s = br.readLine().split(" ");
int n = Integer.parseInt(s[0]);
int x = Integer.par... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 7766750ef62e1da5d42329f11c2f50cc | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
public class And {
public static void main(String[] args) {
FastReader input = new FastReader();
OutputStream ob = System.out;
PrintWriter out = new PrintWriter(ob);
int n = input.nextInt();
int x = input.nextInt();
... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | c09001dc608b22ac12b5b54391acfb00 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.util.*;
import java.math.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
//--------------->>>>IF YOU ARE HERE FOR QUICKSORT HACK THEN SORRY NO HACK FOR YOU<<<-------------------
public class a{
static int[] count,... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 79a681c648f919af2a0bcf171431b085 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
InputStream inpu... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 10d42c42b0c268d419a084a894037862 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.util.Scanner;
public class CF1012B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int x = sc.nextInt();
int[] arr = new int[n];
int[] freq = new int[100100];
for(int i=0; i<n; i++) {
arr[i] = sc.nextInt();
freq[arr[i]]++;
}
boole... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 9ab36e45a28a220b7bf3e6de7e058539 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main
{
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
OutputWriter out = new OutputWriter(System.out);
int n = in.nextInt();
int k = in.nextInt();
int[]a= new int[n];
int[]nums... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | a9fcc1572c69aa52f5945620110931ad | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
public class and
{
public static void main(String args[])throws IOException
{
Buffere... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | fc0d964249ceefe635468107aefa8a86 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 150c3752a552eb3b8c4b1d6e40afc187 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.util.*;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
public class B1013 {
static c... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 2d793af57fd83dbe7ee7638d78a28765 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.util.*;
public class B {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int x = scanner.nextInt();
int[] a = new int[n];
Set<Integer> set = new TreeSet<>();
Set<Integer> setx = new TreeSet<>()... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 039aea370912043ec422c8c450fef461 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | dbff4aee3f1328896b6a313fbeaad6f3 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;
public class Solution
{
static class InputReader
{
private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;
public InputReader(InputStream... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | fd527eb16838d3c1095b688251793320 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.util.*;
public class ques2 {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int n=0,x=0,k=0,c=0;
if(scan.hasNext())
n=scan.nextInt();
if(scan.hasNext())
x=scan.nextInt();
Set<Integer> set=new HashSet<>(),se... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 829b19753fc88ad0a6a8f208a57f4801 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.util.*;
public class and{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int x = in.nextInt();
int[] arr = new int[n];
int[] freq = new int[100000+1];
... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 636b9516d7699e5b3db60b06f0298264 | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes | import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
/**
* @author Avto
* @email avto.bolashvili@maxinai.com
*/
public class Problem {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int x = scanner.next... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | ee641e43b2ff8575dfb24833aef9847b | train_000.jsonl | 1532938500 | There is an array with n elements a1,βa2,β...,βan and the number x.In one operation you can select some i (1ββ€βiββ€βn) and replace element ai with aiβ&βx, where & denotes the bitwise and operation.You want the array to have at least two equal elements after applying some operations (possibly, none). In other wor... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class B {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine()... | Java | ["4 3\n1 2 3 7", "2 228\n1 1", "3 7\n1 2 3"] | 1 second | ["1", "0", "-1"] | NoteIn the first example one can apply the operation to the last element of the array. That replaces 7 with 3, so we achieve the goal in one move.In the second example the array already has two equal elements.In the third example applying the operation won't change the array at all, so it is impossible to make some pai... | Java 8 | standard input | [
"greedy"
] | f4bb0b8f285b0c8cbaf469964505cc56 | The first line contains integers n and x (2ββ€βnββ€β100β000, 1ββ€βxββ€β100β000), number of elements in the array and the number to and with. The second line contains n integers ai (1ββ€βaiββ€β100β000), the elements of the array. | 1,200 | Print a single integer denoting the minimal number of operations to do, or -1, if it is impossible. | standard output | |
PASSED | 09647a7ca7cbb2399f98cf1bc9e29ba5 | train_000.jsonl | 1565188500 | You have a string $$$s$$$ β a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' β move one cell up; 'S' β move one cell down; 'A' β move one cell left; 'D' β move one cell right. Let $$$Grid(s)$$$ be the grid of minimum possible area s... | 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(){
int q=in.nextInt();
for(int i=0;i<q;i++) {
work();
}
out.flush();
}
long mod=1000000007;
l... | Java | ["3\nDSAWWAW\nD\nWA"] | 2 seconds | ["8\n2\n4"] | NoteIn the first query you have to get string $$$\text{DSAWW}\underline{D}\text{AW}$$$.In second and third queries you can not decrease the area of $$$Grid(s)$$$. | Java 8 | standard input | [
"dp",
"greedy",
"math",
"implementation",
"data structures",
"brute force",
"strings"
] | a4f183775262fdc42dc5fc621c196ec9 | The first line contains one integer $$$T$$$ ($$$1 \le T \le 1000$$$) β the number of queries. Next $$$T$$$ lines contain queries: one per line. This line contains single string $$$s$$$ ($$$1 \le |s| \le 2 \cdot 10^5$$$, $$$s_i \in \{\text{W}, \text{A}, \text{S}, \text{D}\}$$$) β the sequence of commands. It's guarantee... | 2,100 | Print $$$T$$$ integers: one per query. For each query print the minimum area of $$$Grid(s)$$$ you can achieve. | standard output | |
PASSED | 6efbdff96920549730888e2f0c0a49a0 | train_000.jsonl | 1565188500 | You have a string $$$s$$$ β a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' β move one cell up; 'S' β move one cell down; 'A' β move one cell left; 'D' β move one cell right. Let $$$Grid(s)$$$ be the grid of minimum possible area s... | 256 megabytes | import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;
public class P1202C {
public static void main(String[] args) {
SimpleScanner scanner = new SimpleScanner(System.in);
PrintWriter writer = new PrintWriter(System.out);
int caseNum = scanner.nextInt();
... | Java | ["3\nDSAWWAW\nD\nWA"] | 2 seconds | ["8\n2\n4"] | NoteIn the first query you have to get string $$$\text{DSAWW}\underline{D}\text{AW}$$$.In second and third queries you can not decrease the area of $$$Grid(s)$$$. | Java 8 | standard input | [
"dp",
"greedy",
"math",
"implementation",
"data structures",
"brute force",
"strings"
] | a4f183775262fdc42dc5fc621c196ec9 | The first line contains one integer $$$T$$$ ($$$1 \le T \le 1000$$$) β the number of queries. Next $$$T$$$ lines contain queries: one per line. This line contains single string $$$s$$$ ($$$1 \le |s| \le 2 \cdot 10^5$$$, $$$s_i \in \{\text{W}, \text{A}, \text{S}, \text{D}\}$$$) β the sequence of commands. It's guarantee... | 2,100 | Print $$$T$$$ integers: one per query. For each query print the minimum area of $$$Grid(s)$$$ you can achieve. | standard output | |
PASSED | b3bb385857e6cdf73f33dd6e2059b11c | train_000.jsonl | 1565188500 | You have a string $$$s$$$ β a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' β move one cell up; 'S' β move one cell down; 'A' β move one cell left; 'D' β move one cell right. Let $$$Grid(s)$$$ be the grid of minimum possible area s... | 256 megabytes | import java.lang.*;
import java.math.*;
import java.util.*;
import java.io.*;
public class Main {
void solve() {
int t=ni();
while(t-->0){
char s[]=ns().toCharArray();
int sz1=0,sz2=0;
for(int i=0;i<s.length;i++){
if(s[i]=='A' || s[i]=='D') sz1++;... | Java | ["3\nDSAWWAW\nD\nWA"] | 2 seconds | ["8\n2\n4"] | NoteIn the first query you have to get string $$$\text{DSAWW}\underline{D}\text{AW}$$$.In second and third queries you can not decrease the area of $$$Grid(s)$$$. | Java 8 | standard input | [
"dp",
"greedy",
"math",
"implementation",
"data structures",
"brute force",
"strings"
] | a4f183775262fdc42dc5fc621c196ec9 | The first line contains one integer $$$T$$$ ($$$1 \le T \le 1000$$$) β the number of queries. Next $$$T$$$ lines contain queries: one per line. This line contains single string $$$s$$$ ($$$1 \le |s| \le 2 \cdot 10^5$$$, $$$s_i \in \{\text{W}, \text{A}, \text{S}, \text{D}\}$$$) β the sequence of commands. It's guarantee... | 2,100 | Print $$$T$$$ integers: one per query. For each query print the minimum area of $$$Grid(s)$$$ you can achieve. | standard output | |
PASSED | 000eaea7e515a1fb76dc29d78dcb0066 | train_000.jsonl | 1565188500 | You have a string $$$s$$$ β a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' β move one cell up; 'S' β move one cell down; 'A' β move one cell left; 'D' β move one cell right. Let $$$Grid(s)$$$ be the grid of minimum possible area s... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in Actual solution is at the top
*
* @author svilen.marchev@gmail.com
*/
p... | Java | ["3\nDSAWWAW\nD\nWA"] | 2 seconds | ["8\n2\n4"] | NoteIn the first query you have to get string $$$\text{DSAWW}\underline{D}\text{AW}$$$.In second and third queries you can not decrease the area of $$$Grid(s)$$$. | Java 8 | standard input | [
"dp",
"greedy",
"math",
"implementation",
"data structures",
"brute force",
"strings"
] | a4f183775262fdc42dc5fc621c196ec9 | The first line contains one integer $$$T$$$ ($$$1 \le T \le 1000$$$) β the number of queries. Next $$$T$$$ lines contain queries: one per line. This line contains single string $$$s$$$ ($$$1 \le |s| \le 2 \cdot 10^5$$$, $$$s_i \in \{\text{W}, \text{A}, \text{S}, \text{D}\}$$$) β the sequence of commands. It's guarantee... | 2,100 | Print $$$T$$$ integers: one per query. For each query print the minimum area of $$$Grid(s)$$$ you can achieve. | standard output | |
PASSED | ed8539bf1bcc4e1d9c5c95992b3c52f5 | train_000.jsonl | 1565188500 | You have a string $$$s$$$ β a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' β move one cell up; 'S' β move one cell down; 'A' β move one cell left; 'D' β move one cell right. Let $$$Grid(s)$$$ be the grid of minimum possible area s... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in Actual solution is at the top
*
* @author svilen.marchev@gmail.com
*/
p... | Java | ["3\nDSAWWAW\nD\nWA"] | 2 seconds | ["8\n2\n4"] | NoteIn the first query you have to get string $$$\text{DSAWW}\underline{D}\text{AW}$$$.In second and third queries you can not decrease the area of $$$Grid(s)$$$. | Java 8 | standard input | [
"dp",
"greedy",
"math",
"implementation",
"data structures",
"brute force",
"strings"
] | a4f183775262fdc42dc5fc621c196ec9 | The first line contains one integer $$$T$$$ ($$$1 \le T \le 1000$$$) β the number of queries. Next $$$T$$$ lines contain queries: one per line. This line contains single string $$$s$$$ ($$$1 \le |s| \le 2 \cdot 10^5$$$, $$$s_i \in \{\text{W}, \text{A}, \text{S}, \text{D}\}$$$) β the sequence of commands. It's guarantee... | 2,100 | Print $$$T$$$ integers: one per query. For each query print the minimum area of $$$Grid(s)$$$ you can achieve. | standard output | |
PASSED | c7d29130a691a4de39244c20a04b38e0 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t-->0) {
int n =scan.nextInt();
String str= scan.next();
System.out.println(count(str,'a'));
}
scan.close();
... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 87ca6cc994feeb7a15aac0064f7dd353 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
final static int maxn = 1000;
static Scanner reader = new Scanner(System.in);
static int n;
static int val[][];
static int lens[];
static String s;
static int cnt_dp(int let, int pos) {
if(lens[let] == 1)
re... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | da4804696e78c86639fb61267657267d | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
/**
* @author Tran Anh Tai
* @template for CP codes
*/
public class ProbD {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputR... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 1445e65ba737c234fa280472a3a47664 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.*;
import java.math.*;
import java.util.*;
public class Main implements Runnable {
class Pair implements Comparable<Pair>{
public int node;
public int count;
Pair(int nd, int c){
node=nd; count=c;
}
public int compareTo(Pair that) {
return that.count - this.count;
}
}
i... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 764fcf3268aadb87855b0407883e3575 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Q417July {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t!=0){
t--;
int n = sc.nextInt... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 3a461460176264565e45e74389ad8e09 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
public class scratch_25 {
static class Reader {
static BufferedReader reader;
static StringTokenizer tokenizer;
/**
* call this method to... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | c167887adf104d6e2a2cad8c3b6eb1bc | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | /*package whatever //do not write package name here */
import java.io.*;
import java.util.*;
public class GFG {
public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
String str=sc.next();
int res=Integer.MAX_VALUE... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 04c3773e3e4c3943e7a3985269f7b6d4 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
Input... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 14801bf036363719f726e9e2552b30e1 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
Input... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 500c3971f4e33585d02d88ee3f193eff | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.Scanner;
public class D{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
// input.nextLine();
while(t-- != 0){
int n = input.nextInt();
input.nextLine();
String s = input.nextLine();
System.out.println(solve(s, 'a', 0));
... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 02920d500c608bcdb9b7a3f89e2c91fd | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.*;
import java.util.*;
public class codeforces {
public static void main(String[] args) {
InputReader sc = new InputReader(System.in);
int T=sc.nextInt();
for (int t = 0; t < T; t++) {
int n=sc.nextInt();
String str=sc.nextLine();
out.prin... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 2a1d7bdc50bfdce77300e4afbdc25284 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 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.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
public class Solution1385D {
public st... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 96b87af808c0547e2b345d283cc0ac3b | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 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.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
public class Solution1385D {
public st... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 3f5e76206e16e5a0b5f19ed7b0109b5b | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.Scanner;
public class CF_Round_656_Div3_ProblemD_ {
public static void main(String[] args) {
process();
}
public static void process() {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
for(int i = 0; i < t; ++i) {
int n = sc... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | b024ad5caaf47473bcc2c89a2567cd0f | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class D {
// C-good StringμΌλ‘ λ§λλλ° νμν μ΅μ λ체 μ λ°ν
static int aGood(String S, char C) {
if (S.length() == 1) {return S.charAt(0) != C ? 1 : 0;}
int ... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 7dce0099bf462b7061f9ce541b101755 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public final class CodeForces {
static int ans;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.pars... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 8e066b4408a10d6f05a736686c4ac06c | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import com.sun.org.apache.xpath.internal.SourceTree;
import com.sun.org.apache.xpath.internal.functions.FuncFalse;
import javafx.util.Pair;
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Contest {
public static class pair implements Comparable<pair> {
long l;
l... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 43ebf485014dd60a741371166e824d3d | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Pranay2516
*/
public class... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | a1a8e0811f73caa5e74381e2fb044130 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
import java.io.*;
public class AGoodString656D{
static class FastReader {
BufferedReader br;
StringTokenizer st;
private FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null ... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 63e8ae36bf1cd81a3d938e9cec54bafe | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 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.Comparator;
import java.util.Objects;
import java.util.StringTokenizer;
import java.util.function... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 486836da6cf4de505f88100ef4652fce | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
public class Main
{
public static int getAns(String str,char ch,HashMap<String,Integer> map)
{
String temp=str+"|"+ch;
if(str.length()==1)
{
if(str.charAt(0)==ch)return 0;
else return 1;
}
if(map.containsKey(temp))return ma... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 712520c80261878d7a6765a710ad36f3 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
public class Main
{
public static int getAns(String str,char ch)
{
if(str.length()==1)
{
if(str.charAt(0)==ch)return 0;
else return 1;
}
int firstHalf=0,secondHalf=0;
for(int i=1;i<=str.length();i++)
{
i... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | fe46086f61692c4faf09b338554ff51b | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
public class Main{
public static int min(String s,int start,int end,char c){
if(start==end){
if(s.charAt(start)==c) return 0;
else return 1;
}
int mid=(start+end)/2;
char d=(char)(c+1);
int cnt1=(end-start+1)/2;
int cnt2=cnt... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | e859e6aac489e7fbeae472214784ce0f | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Scanner;
public class Div656 {
static Scanner sc =new Scanner(System.in);
static PrintWriter out =new PrintWriter(System.out);
public static void ThreePairwiseMaximums() {
int t=sc.nex... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | b604a48f7563cfb3a955ae79ff9b58b5 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
private static FastReader fr = new FastReader();
private static Helper hp = new Helper();
private static StringBuilder result = new StringBuilder();
public static void main(String[] args) {
Task solver = new Task();... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 07327962201527a88662d049b20abfd7 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
private static FastReader fr = new FastReader();
private static Helper hp = new Helper();
private static StringBuilder result = new StringBuilder();
public static void main(String[] args) {
Task solver = new Task();... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 38c1bede7976eff5a97ef0e110e34ec3 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
static String s="";
public static void main (String[] args) throws java.lang.Exception
{
Scanner in=new S... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | e1c885579d2ca30f3528f96dda277e80 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
import java.io.*;
//import java.math.*;
public class Task{
// ..............code begins here..............
static long mod=(long)998244353;
static int res=998244353;
static String ss="abcdefghijklmnopqrstuvwxyz";
static void rec(char[] c, int c1,int i,int j,int tmp){
char cc=ss.charAt(c1... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 29de9289195860eb57dec0edeab07367 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes |
import java.util.*;
import java.io.*;
public class CF1385D {
static FastReader in = new FastReader();
public static void main(String[] args) {
int t = in.nextInt();
while(t-- > 0) solve();
}
static void solve() {
String[] alph = "abcdefghijklmnopqrstuvwxyz".split("");
int n = in.nextInt();
String s = ... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 6ba98d717d5da1fb3451e465f0064b84 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes |
import java.util.*;
import java.io.*;
public class CF1385D {
static FastReader in = new FastReader();
public static void main(String[] args) {
int t = in.nextInt();
while(t-- > 0) solve();
}
static void solve() {
String[] alph = "abcdefghijklmnopqrstuvwxyz".split("");
int n = in.nextInt();
String s =... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 5726dabba4de90ddbd3baecb22ef6f2c | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
import java.lang.*;
public class Main
{
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while ( t-- > 0 ) {
int n = scanner.nextInt();
String s = scanner.next();
System.out.... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 97506eaa9dbb29e1df005a8be22994da | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main
{
public static int dac(char carr[],int c,int l,int r)
{
if(l==r)
{
if((carr[l]-'a')==c)
return 0;
return 1;
}
int mid=(l+r)/2;
int cntr1=0,cntr2=0;
for(int i=l;i<=mid;i++)... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | e07cb2b250456997a2474780805324e0 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | //created by Whiplash99
import java.io.*;
import java.util.*;
public class D
{
private static int solve(char[] str, int l, int r, char cur)
{
if(l==r) return str[l]==cur?0:1;
int mid=(l+r)/2;
int c1=0,c2=0;
for(int i=l;i<=mid;i++) if(str[i]!=cur) c1++;
for(int i=mid+1;i<... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 1a8d02cd2f2e73ef9b17d79b75bfb93f | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.Scanner;
public class hello {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
char checker = 'a';
String s = sc.next();
int ans = getM... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 08959ac66e8b550bfdb0ae2cd6fbadb6 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitS... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | b212ddc0bf140358a3d309a411b792f0 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class A_Good_String
{
InputReader in;PrintWriter pw;
char str[];
long pow(long base,long power)
{
if(power==0) return 1L;
long temp = 1L;
if(power%2==1)
{
temp = base;
}
base = (base*base);
return (temp*pow(base,power/2L));
}
lon... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 0123e9939c7540ccffe900a554cfb31c | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | // _________________________RATHOD_____________________________________________________________
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class Main
{
static ArrayList<A... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 44c9709b6493f3749244de3d735474a5 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class temp {
pu... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 5990fa7a594b34511e3f449596146777 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class temp {
Ha... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 84d638eb137d2b023e5dab8b268fc781 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main{
static CustomScanner input;
static PrintWriter out;
public static void main(String commandLineArgument[]){
input = new CustomScanner();
out = new PrintWriter(System.out);
int tc = input.nextInt();
while(tc --> 0) {
... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 35fd0aebf06df47200d8390a06ca3a16 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main{
static CustomScanner input;
static PrintWriter out;
public static void main(String commandLineArgument[]){
input = new CustomScanner();
out = new PrintWriter(System.out);
int tc = input.nextInt();
while(tc --> 0) {
... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | a2f00eec23f7c040afa6be35d0037c36 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
public class Main {
static int c=0;
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int t=in.nextInt();
while(t-->0) {
int n=in.nextInt();
String str=in.next();
int z=good(str, 0, str.length()-1, 'a');
System.out.println(z);
}
}
public st... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | cd995bcbcde3d1f4572098f555007105 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 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 = Syste... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 179c4f8f2fd0f2722fa605d6daa036cb | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | // coded by Krishna Sundar //
import java.lang.*;
import java.io.*;
import java.util.*;
public class Main {
private int calc(int[][] count, int start, int end, int C) {
return count[end][C]-(start-1<0?0:count[start-1][C]);
}
private int GO(String str, int[][] count, int start, int end, int C) {
... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | f493edba6d1015957c44f2dd70eb2180 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Code {
public static void main(String[] args) throws IOException
{
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
StringBuilder res = new StringBuilder(... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 28702d95da34480a896468c7bf9a03fd | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 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 Main
{
public static void main (String[] args) throws java.lang.Exception
{
BufferedReader bf = new BufferedReader(new ... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 87baec73aae549bad2c2a2996d07b370 | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes | import java.util.*;
public class cfgs{
static int goods(String s,int strs,int stre,int ctf)
{
if(strs==stre)
{
char c=(char)(97+ctf);
if(s.charAt(strs)!=c)
return 1;
else
return 0;
}
... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 237622316fb4e28d6ed75ad630346d6f | train_000.jsonl | 1594996500 | You are given a string $$$s[1 \dots n]$$$ consisting of lowercase Latin letters. It is guaranteed that $$$n = 2^k$$$ for some integer $$$k \ge 0$$$.The string $$$s[1 \dots n]$$$ is called $$$c$$$-good if at least one of the following three conditions is satisfied: The length of $$$s$$$ is $$$1$$$, and it consists of t... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
public class D {
public static int replace(String s,char c) {
int ans=0;
for(char c1:s.toCharAr... | Java | ["6\n8\nbbdcaaaa\n8\nasdfghjk\n8\nceaaaabb\n8\nbbaaddcc\n1\nz\n2\nac"] | 2 seconds | ["0\n7\n4\n5\n1\n1"] | null | Java 8 | standard input | [
"dp",
"bitmasks",
"implementation",
"divide and conquer",
"brute force"
] | 324b7957b46dfe4948074c781159b7e7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 131~072$$$) β the length of $$$s$$$. It is guaranteed that $$$n = 2^k$$$ for some integer $$$... | 1,500 | For each test case, print the answer β the minimum number of moves required to obtain an 'a'-good string from $$$s$$$ (i.e. $$$c$$$-good string with $$$c =$$$ 'a'). It is guaranteed that the answer exists. | standard output | |
PASSED | 48965e532f595240288b631f9d878991 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.math.*;
import java.io.*;
public class C408C{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String[] num1=br.readLine().split(" ");
int A=Integer.parseInt(num1[0]);
int B=Integer.parseInt(num1[1])... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 336f5e550389065b158b9b569d699116 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.util.Scanner;
public class test {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
double a = input.nextInt();
double b = input.nextInt();
input.close();
double c = a * a + b * b;
double xA = 0, yA = 0, xB = 0, yB = 0;
... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 4ea4226af5fba4d186e36dc29928b1e5 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
public class solver implements Runnable {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTok... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | ee27e7b44151c825aa5d4e47255daf1f | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.util.*;
public class C {
Scanner sc = new Scanner(System.in);
void doIt() {
int a = sc.nextInt();
int b = sc.nextInt();
if(a > b) { int tmp = a; a = b; b = tmp; } // swap
for(int x = 1; x < a; x++) {
for(int y = 1; y < a; y++) {
if(x*x + y*y == a*a) { // candidate
int m = x * b / a;
... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 1101be5a1e5e446a1330f7143a66e4bd | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.util.*;
public class a {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int a = input.nextInt(), b = input.nextInt();
int g = gcd(a, b);
if(a>b)
{
int temp = a;
a = b; b = temp;
}
int[] first = py(g);
if(first.length == 0 || f... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | b4304372312fdb0fa580adfef939f6c8 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class CF239CDev2 {
class Triangle implements Comparable<Triangle> {
int a, b, c;
Triangle(int a, int b, int c) {
this.a = a;
this.b = b;
this.c = c;
}
@Override
pu... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 7341466de7441f565bac53409aaa5814 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
/**
* Created by Vadim Semenov on 30-03-2014.
*/
public class TaskC implements Runnable {
private Output solve(Input input) {
for (int i = 1; i <= input.b; i++) {
for (int j = 1; j < i; j++) {
int k = i - j;
i... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | df489870b1f194e987454e621900b0d4 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.util.List;
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author desc
*/
public class Main {
public static void m... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 9a912d2547236b5b6f8caf0fc51ecbef | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.util.*;
import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
public class C1
{
FastScanner in;
PrintWriter out;
public int gcd(int a, int b)
{
while (b !=0)
{
int tmp = a % b;
a = b;
b = tmp;
}
... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 9a5b9b1032017c0998099363ce792103 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Triangle {
static class Point {
long x, y;
Point(long x, long y) {
this.x = x;
this.y = y;
}
public long sqDist(Point o) {
long xD... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | d7f0c21490686b8b90f3150f66c42ee5 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.io.*;
import java.util.*;
public class C {
BufferedReader br;
StringTokenizer in;
PrintWriter out;
int b;
final double eps = 0.00001;
final double pi = 3.141592653;
public String nextToken() throws IOException {
while (in == null || !in.hasMoreTokens()) {
in... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 40e8c91f941146b5d47fd93fec1e9bab | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.util.*;
public class C {
Scanner in = new Scanner(System.in);
void run() {
int a = in.nextInt();
int b = in.nextInt();
int b2 = b * b;
for (int x = b - 1; x > 0; x--) {
int x2 = x * x;
if (x2 >= b2) {
break;
... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 26d932c51e70a78acbc51516d4601797 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.Scanner;
public class C239 {
public class solution {
int x1;
int y1;
int x2;
int y2;
int x3;
int y3;
public solution() {
x1 = x2 = y1 = y2 = x3 = y3 = 0;
}
}
static boolean perfect(int num) {
double s = ... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 6f27df35ae13c4980108f619f33d7f25 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.Scanner;
public class C239 {
public class solution {
int x1;
int y1;
int x2;
int y2;
int x3;
int y3;
public solution() {
x1 = x2 = y1 = y2 = x3 = y3 = 0;
}
}
static boolean perfect(int num) {
double s = ... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 76acd072883d57c4d3997116916c72f6 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main implements Runnable {
final boolean isFileIO = false;
BufferedReader in;
PrintWriter out;
StringTokenizer st = new StringTokenizer("");
String delim = " ";
public static void main(String[] args) {
new Thread(null, new Main(), "", 268435456).st... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | b6d3e0f3478aae63a2d6f4c7d2e0a9b4 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.awt.geom.Point2D;
import java.util.*;
public class Main {
Scanner in = new Scanner(System.in);
public static void main(String[] args) {
new Main();
}
public Main(){
new C().doIt();
}
class C{
double EPS = 1.0e-8;
Point2D normalVector1(Point2D p){
return new Point2D.Double(-p.getY(), p.... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 263e49ccf1aac085aceed23964cc7111 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
import java.util.Vector;
/**
* Created by Praveen on 3/30/14.
*/
public class B
{
public static void main(String[]args)
{
InputReader in=new InputReader(System.in);
PrintWriter out=new PrintWriter(System.out);
int a=in.nextInt();
... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 749abaa8b3e8bbcf9a7f9bd425ffa8c0 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.awt.geom.Point2D;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
int y1,x1,y2,x2;
int cnt = 0;
for(int i = 1;i < n;i++){
i... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | a9f896c930dae030d46f9977f6a2c45f | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
public class C_Triangle_r239d2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int r1 = sc.nextInt();
int r2 = sc.nextInt();
HashMap<Integer, Integer> sqrt = new HashMap<Integer, Integer>();
for(... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 2b1af829471f6757760400797be34ff8 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.math.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
import static java.util.Collections.*;
import static java.lang.System.out;
public class Main {
static boolean LOCAL = System.getSecurityManager() == null;
Scanner i... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 527931542f18a7cf1aa3398f4bfd85db | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.math.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
import static java.util.Collections.*;
import static java.lang.System.out;
public class Main {
static boolean LOCAL = System.getSecurityManager() == null;
Scanner i... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | d6dd05df6873f03e0a0d575790dc71c2 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.util.Scanner;
public class C {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
for (int x_a = 1; x_a <= a; x_a++) {
double yy_a = a*a - x_a*x_a;
double y_a = Math.sqrt(yy_a);
if (y_a == (int) y_a) {
for (int x_... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | b4af96542be1ac4db143a0337b644d93 | train_000.jsonl | 1396162800 | There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the app... | 256 megabytes | import java.util.Scanner;
public class C {
public static void main(String[] args) {
new C();
}
public C() {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
boolean found = false;
int solx1 = 0;
int solx2 = 0;
int soly1 = 0;
int soly2 = 0;
for (int i = 1; i < a... | Java | ["1 1", "5 5", "5 10"] | 1 second | ["NO", "YES\n2 1\n5 5\n-2 4", "YES\n-10 4\n-2 -2\n1 2"] | null | Java 7 | standard input | [
"geometry",
"math"
] | a949ccae523731f601108d4fa919c112 | The first line contains two integers a,βb (1ββ€βa,βbββ€β1000), separated by a single space. | 1,600 | In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute valu... | standard output | |
PASSED | 1b018d96fb6f971029ca0250ffe2c3d2 | train_000.jsonl | 1593873900 | This is an interactive problem.Anton and Harris are playing a game to decide which of them is the king of problemsetting.There are three piles of stones, initially containing $$$a$$$, $$$b$$$, and $$$c$$$ stones, where $$$a$$$, $$$b$$$, and $$$c$$$ are distinct positive integers. On each turn of the game, the following... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
// +8
public class cf1375f {
public static void main(String[] args) throws IOException {
long a[][] = new long[3][2];
r();
for (int i = 0; i < 3; ++i) {
a[i][0] = nl();
... | Java | ["5 2 6\n\n\n3\n\n0"] | 1 second | ["First\n2\n\n3"] | NoteIn the sample input, the piles initially have $$$5$$$, $$$2$$$, and $$$6$$$ stones. Harris decides to go first and provides the number $$$2$$$ to Anton. Anton adds $$$2$$$ stones to the third pile, which results in $$$5$$$, $$$2$$$, and $$$8$$$.In the next turn, Harris chooses $$$3$$$. Note that Anton cannot add th... | Java 11 | standard input | [
"math",
"constructive algorithms",
"games",
"interactive"
] | 351c6fb0a9d1bbb29387c5b7ce8c7f28 | The first line of input contains three distinct positive integers $$$a$$$, $$$b$$$, and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) Β β the initial number of stones in piles $$$1$$$, $$$2$$$, and $$$3$$$ respectively. | 2,600 | null | standard output | |
PASSED | 563e10e72387c586edfd4e808585260f | train_000.jsonl | 1593873900 | This is an interactive problem.Anton and Harris are playing a game to decide which of them is the king of problemsetting.There are three piles of stones, initially containing $$$a$$$, $$$b$$$, and $$$c$$$ stones, where $$$a$$$, $$$b$$$, and $$$c$$$ are distinct positive integers. On each turn of the game, the following... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class cf1375f {
public static void main(String[] args) throws IOException {
long a[] = rla(3), op;
prln("First");
flush();
prln(op = maxof(a));
flush();
a... | Java | ["5 2 6\n\n\n3\n\n0"] | 1 second | ["First\n2\n\n3"] | NoteIn the sample input, the piles initially have $$$5$$$, $$$2$$$, and $$$6$$$ stones. Harris decides to go first and provides the number $$$2$$$ to Anton. Anton adds $$$2$$$ stones to the third pile, which results in $$$5$$$, $$$2$$$, and $$$8$$$.In the next turn, Harris chooses $$$3$$$. Note that Anton cannot add th... | Java 11 | standard input | [
"math",
"constructive algorithms",
"games",
"interactive"
] | 351c6fb0a9d1bbb29387c5b7ce8c7f28 | The first line of input contains three distinct positive integers $$$a$$$, $$$b$$$, and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) Β β the initial number of stones in piles $$$1$$$, $$$2$$$, and $$$3$$$ respectively. | 2,600 | null | standard output | |
PASSED | 0e786332ba7f15d094a64b442a0cc8e5 | train_000.jsonl | 1593873900 | This is an interactive problem.Anton and Harris are playing a game to decide which of them is the king of problemsetting.There are three piles of stones, initially containing $$$a$$$, $$$b$$$, and $$$c$$$ stones, where $$$a$$$, $$$b$$$, and $$$c$$$ are distinct positive integers. On each turn of the game, the following... | 256 megabytes | import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.exit;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java... | Java | ["5 2 6\n\n\n3\n\n0"] | 1 second | ["First\n2\n\n3"] | NoteIn the sample input, the piles initially have $$$5$$$, $$$2$$$, and $$$6$$$ stones. Harris decides to go first and provides the number $$$2$$$ to Anton. Anton adds $$$2$$$ stones to the third pile, which results in $$$5$$$, $$$2$$$, and $$$8$$$.In the next turn, Harris chooses $$$3$$$. Note that Anton cannot add th... | Java 11 | standard input | [
"math",
"constructive algorithms",
"games",
"interactive"
] | 351c6fb0a9d1bbb29387c5b7ce8c7f28 | The first line of input contains three distinct positive integers $$$a$$$, $$$b$$$, and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) Β β the initial number of stones in piles $$$1$$$, $$$2$$$, and $$$3$$$ respectively. | 2,600 | null | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.