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 | 39e41a4bc0793fe587b7a8b0f45c8ff5 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | //package Div2.C;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class GuessingTheGreatest {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.pa... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | c9fc47f7fcb5eec27c5bb5b8a2252a10 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main{
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringT... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 30bc9cd673ff25b5e2afc80c650eaf09 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
public class C1 {
public static void main(String[] args) throws IOException{
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
int n = Integer.parseInt(... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | a876a787d6dd8fbdedfd0abbe0ca0332 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class First {
public static void main(String[] args) {
InputStream inputStream = System.in... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 8ff02311818260a78fa051153ad435dd | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class First {
public static void main(String[] args) {
InputStream inputStream = System.in... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | d8849ec148c1a39f177f72df222bfd5b | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes |
import java.util.*;
import java.io.*;
public class Main {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
static int n;
static Scanner sca = new Scanner(System.in);
public static void main(Strin... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 3fdc8a837ed89a428333f7c1349eb670 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
public class GuessingTheGreatestEasyVersion {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int l = 1, r = N;
while (l < r) {
System.out.println("? " + l... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 7fb06d7201f3cbde573d8c120cb2ce9e | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes |
import java.io.*;
import java.util.*;
import java.util.function.BiFunction;
public class C {
static FastReader reader = new FastReader();
static OutputWriter out = new OutputWriter(System.out);
static int ask(int l, int r) {
out.println("? " + l + " " + r);out.flush();
return... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | a4ac08ecc0e6fb94e6d0650266bbac44 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 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.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
im... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 7763e7d70d42e50259a1ad47efc0bf47 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | //I AM THE CREED
/* //I AM THE CREED
/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
import java.awt.Point;
public class Main{
static final Random ran... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | f124f6265ebd1eae4b24ac51adaee91b | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | //I AM THE CREED
/* //I AM THE CREED
/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
import java.awt.Point;
public class Main{
static final Random ran... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | d6ffb75654dc1d4d385b1a0901aef17b | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
public class Solution {
private static boolean TESTS = false;
private final Input in;
private final PrintStream out;
public Solution(final Input in, final PrintStream out) {
this.in = in;
this.out = out;
}
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 078b615be100ce738060eb5293d4569c | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws Exception
{
FastReader fr=new FastReader();
int n=fr.nextInt();
System.out.println("? "+1+" "+n);
System.out.flush();
int sma... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 7e10692e40f576d397838561f6e51fc5 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.io.InputStream;
/**... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 8d932cf557003c8e142d222593b465b4 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import javax.print.DocFlavor;
import javax.swing.text.html.parser.Entity;
import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
public class Main {
static FastScanner sc;
static PrintWriter pw;
stati... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 62ccc12d2dddd60fb38b4660fd50473f | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.Scanner;
public class GuessingtheGreatest {
static Scanner input=new Scanner(System.in);
public static void main(String[] args) {
response();
}
public static void response() {
int n=input.nextInt();
int l=1;
while(l!=n) {
System.out.println("? "+l+" "+n);
Sy... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 98a034e0c1f87a5e93fc8ad1ca748fde | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class C {
static BufferedReader br;
public static void main(String[] args) throws NumberFormatException, IOException {
// TODO Auto-generated method stub
br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readL... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | d058b8c3fbb75758bbdbc5704cb25c36 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | // No sorcery shall prevail. //
import java.util.*;
import java.io.*;
public class InVoker {
//Variables
static long mod = 1000000007;
static long mod2 = 998244353;
static FastReader inp= new FastReader();
static PrintWriter out= new PrintWriter(System.out);
public static void main(String args... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 74806841db666f206fe6389c07fe550c | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Solution1486C1 {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWrite... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 3961ca36ece16df06c6276a0ceac6dc9 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.TimeUnit;
public class c1486 implements Runnable{
public static void main(String[] args) {
try{
new Thread(null, new c1486(), "process", 1<<26).start();
}
catch(Exception e){
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | a30bef7b18284531dc00636d053a5fb6 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
public class C1486 {
static int n;
static Scanner sc;
static PrintWriter pw;
public static int query(int l, int r) throws IOException {
pw.printf("? %d %d%n", l, r);
pw.flush();
return sc.nextInt();
}
public static void ans(int idx) throws IOException {... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 0a57537666256acdbfc84c5906c90593 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
public class C {
static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.printf("? %d %d\n", 1, n);
int m = sc.nextInt();
if(m > 1) {
System.out.printf("? %d %d\n", 1, m);
int r = sc.nextInt();
if(r =... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | e211285fcbe3823de086221fff45efd7 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static BufferedReader bf;
static PrintWriter out;
static Scanner sc;
static StringTokenizer st;
static long mod = (long)(1e9+7);
static long mod2 = 998244353;
static long fact[] = new long[1001];
static long inverse[] = new long[1001];
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | baa544e9f6ef824f2ce0485378f9c96a | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes |
import java.util.*;
import java.io.*;
public class Guessing_the_greatest {
static StringBuilder sb;
static dsu dsu;
static long fact[];
static long mod = (int) (1e9);
static void solve() {
int n = i();
int lo = 1;
int hi = n+1;
while(lo+1 < hi){
int mid = lo + (hi-lo)/2;
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 93a0a9f9383b76f5952a46c3d278001a | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class C {
public static void main(String[] args) {
FastReader f = new FastReader();
StringBuffer sb=new StringBuffer();
int n=f.nextInt();
int l=1,r=n;
while(l<r)
{
System.out.println("? "+l+" "+r);
int idx=f.nextInt();
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 440859651192d8a3cafe04757375f2e4 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String args[])
{
FastReader input=new FastReader();
PrintWriter out=new PrintWriter(System.out);
int T=1;
while(T-->0)
{
int n=input.nextInt();
int l=1,r=n... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 3bc69ce453afd2cbc6310ae1e07bd20c | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | //package Current;
import java.util.*;
public class Main {
static final long mod = (long) 1e9 + 7;
static class pair {
int x, y;
public pair(int x, int y) {
this.x = x;
this.y = y;
}
}
public static void main(String args[]) {
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 03533505d4e7abeb1039c04e7db209a6 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main implements Runnable {
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private Spa... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 7aa762c81628afc6ced68cec0937f83c | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static PrintWriter pw;
static Scanner sc;
static long ceildiv(long x, long y) { return (x+y-1)/y; }
static int mod(long x, int m) { return (int)((x%m+m)%m); }
static void put(HashMap<Integer, Integer> map, Integer p){if(map.containsK... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 6f2b37452ac46eb460ec0b08603ed284 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | /*
* akshaygupta26
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashS... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | ea52cb234c21ef2b4be9554f861809fc | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | /*
* akshaygupta26
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashS... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | b13c21e6207cbc225dc352fcc12bddf0 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;import java.util.*;import java.math.*;
public class Main
{
static long mod=1000000007l;
static int max=Integer.MAX_VALUE,min=Integer.MIN_VALUE;
static long maxl=Long.MAX_VALUE,minl=Long.MIN_VALUE;
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
sta... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | c7bf03c8437d4a7e43420c2f8b994e77 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | // package com.company;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Main main = new Main();
main.solve();
}
public void solve() {
Scanner in = null;
PrintWriter out = null;
try {
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 949c824e236b2d5a48c65f832903f615 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class A implements Runnable {
public void run() {
long startTime = System.nanoTime();
int n = nextInt();
int[] f = new int[31];
f[1] = 2;
f[2] = 3;
for (int i = 3; i <= 24; i++) {
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 8bbae4905eddce5383da6202f274c53c | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.math.BigInteger;
import java.util.*;
public class abc {
static int[] arr;
static int firstOcc(int n, int key) {
if (n == arr.length) return -1;
else {
if (arr[n] == key) return n;
int i = firstOcc(n + 1, key);
if (i == -1) return -1;
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | a38f70bfd4d3f852f3701ae8fd7b7907 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.function.BinaryOperator;
import java.util.stream.Collectors;
public class Main {
private final static long mod = 1000000007;
private final static int MAXN = 1000001;
private static long power(long x, long y, long m) {
long temp... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | ae27ae18755b92e3571742917fa6120e | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
static FastScanner fs;
public static void main(String[] args) {
fs=new FastScanner();
// int t = fs.nextInt();
// while (t-->0)
solve();
}
public static void solve() {
int n = fs.nextInt();
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 7e84af4297515a3ee744ff8a03a09563 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class TaskA {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
Task solver = new Task();
solver.solve(in, out);
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 4326d2658ea75c942124f340323f3578 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | // package com.company;
import java.sql.SQLOutput;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class HM3 {
static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
public static void main(String[] Args)throws E... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | a50cd0e39d0a811f1c2c376557003568 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
int n=sc.nextInt();
pw.println("? "+1+" "+n);
pw.flush();
int v=sc.nextInt();
int x=0;
if(v!=1) {
pw.println("? "+1+" "+v);
pw.flush();
x=sc.nextInt();
}
if(x==v&&... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 172cb4a06a9c9027f3966687d6d00b9d | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import javax.sound.midi.Track;
import java.io.*;
public class tr0 {
static PrintWriter out;
static StringBuilder sb;
static long mod = (long) 1e9 + 7;
static long inf = (long) 1e16;
static int n, m;
static ArrayList<Integer>[] ad;
static int[][] remove, add;
static int[][] m... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | ae722c59bc1c5cb3780e93795d21eb93 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | //stan hu tao
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;
public class x1486C1
{
public static void main(String hi[]) throws Exception
{
BufferedReader infile = new BufferedRe... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 8635125a3e4af29dbbcbbed7bba544dc | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.Scanner;
public class C1486 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
System.out.println("? 1 " + N);
System.out.flush();
int second = in.nextInt();
int low = -1;
int hig... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | e469780127ce6e69507f8096250469ca | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
public class codeforces1486C1 {
static PrintWriter pw;
public static void main(String[] args) throws Exception {
FastScanner in = new FastScanner();
pw = new PrintWriter(System.out);
int n = in.nextInt();
int low = 1;
int h... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 8549e7f2daaa8aaf019e31318d589d42 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
////***************************************************************************
/* public class E_Gardener_and_Tree implements Runnable{
public static void main(String[] args) throws Exception {
new Thread(null, new E_Gardener_and_Tree(), "E_Gardener_and_Tr... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 16c278e165609a4270663ee4c44e5e4a | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 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.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
im... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | de8739a06f45ea132b78db2117954f64 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.text.*;
import java.util.*;
import java.util.function.*;
/**
* Provide prove of correctness before implementation. Implementation can cost a lot of time.
* Anti test that prove that it's wrong.
* <p>
* Do not confuse i j k g indexes, upTo and length. Do extra methods!!! Write... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 17 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | b7beaaabb9e1e0a0f0f1d6e2b6184797 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.text.*;
import java.util.*;
import java.util.function.*;
/**
* Provide prove of correctness before implementation. Implementation can cost a lot of time.
* Anti test that prove that it's wrong.
* <p>
* Do not confuse i j k g indexes, upTo and length. Do extra methods!!! Write... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 17 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | a301afcef0898e8c02295ba413a018f2 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes |
import java.util.*;
import java.io.*;
public class GuessingTheGreatest_Hard {
public static void main(String[] args) throws IOException {
Soumit sc = new Soumit();
int n = sc.nextInt();
System.out.println("? 1 "+n);
System.out.flush();
int smax_ind = sc.ne... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 17 | standard input | [
"binary search",
"interactive"
] | b3e8fe76706ba17cb285c75459508334 | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,600 | null | standard output | |
PASSED | 4949f2a7e8657939bc09e72b0052b732 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Random;
import java.util.StringTokenizer;
public class TaskC {
static long mod = (long) (1000000000+7);
public static void main(String[] args) {
// TODO Auto-generated... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | bd056ccd8ccf29f530a92e7767073478 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class GuessingTheGreatestHard {
MyScanner scanner = new MyScanner();
private int solve(int n) {
// if (n == 2) { // 1, 2
// int secMax = ask(0, 1);
// ... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 140d1133b031c3b420aa33827cd7cc8e | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class GuessingTheGreatestHard {
MyScanner scanner = new MyScanner();
private int solve(int n) {
if (n == 2) {
int secMax = ask(0, 1);
if (secMax... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | f35e099391176010973c5c9bd4518183 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class GuessingTheGreatestHard {
MyScanner scanner = new MyScanner();
private int solve(int n) {
if (n == 2) {
int secMax = ask(0, 1);
if (secMax... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 71306d07a6bda08c8ba8679c4838cd09 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Problem {
private static BufferedReader reader;
private static int ask(int l, int r) throws IOException {
if (l==r) return -1;
System.out.println("? "+(l+1)+" "+(r+1));
int... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 6b1e76354db42178442bed4d7db54af9 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
private static BufferedReader reader;
private static int ask(int l, int r) throws IOException {
if (l>=r) return -1;
System.out.println("? " + (l+1) + " " + (r+1));
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | fd6beedc231c1ea2e8a255f59cee3176 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes |
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
public class Main {
static class point {
long val, time, t3;
point(long val, long time, int t3) {
this.val = val;
this.time = time;
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 5197ab3c870fdc5fdda84f53e6d4e5bb | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class MainC {
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 629fea3c1fe10d868b7fdc8ac191909b | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | /*
* akshaygupta26
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashS... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 29a289fea5a6adf464d7ee9c8a32c166 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
public class C
{
static Scanner in;
public static void main(String[] args) {
in = new Scanner(System.in);
int n = in.nextInt();
int l=1, r= n;
int s = query(l, r);
if(query(1, s) == s) {
l = 1; r = s-1;
while(l<r) ... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | df48168e3559c79ffa9ef82794a14f3c | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main{
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringT... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 9144417b05a2aa6beab4af8a2d7efdfd | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
import java.text.*;
public class Main implements Runnable {
FastScanner sc;
PrintWriter pw;
final class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
try {
br = new Bu... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | e1781b02f93ec75611af66c5d809540c | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
public class CA2 {
static FastScanner sc = new FastScanner();
public static void main(String[] args) {
PrintWriter out = new PrintWriter(System.out);
int n = sc.nextInt();
out.println("! " + solve(n));
out.close();
}
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 2aee81ceb08f2170c96f21bdff898649 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
public class C2 {
static FastScanner sc = new FastScanner();
public static void main(String[] args) {
PrintWriter out = new PrintWriter(System.out);
int n = sc.nextInt();
out.println("! " + solve(n));
out.close();
}
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 5f436ffe24133f7fcc9c7dc50b6582b8 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.util.concurrent.LinkedBlockingDeque;
import javax.print.attribute.IntegerSyntax;
import javax.sql.rowset.spi.SyncResolver;
import java.io.*;
import java.nio.channels.NonReadableChannelException;
import java.text.DateFormatSymbols;
import static java.lang.System.*;
public ... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | b2fb83d24a7fdd74d059b72b0747a3ea | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public final class Solution {
static PrintWriter out = new PrintWriter(System.out);
static FastReader in = new FastReader();
static long mod = (long) 1e9 + 7;
static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(1, 0), new Pair(0, -1), new Pair(0, ... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | aa4f947d70c93e11fe0f2336e0c1395e | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
PrintWriter out = new PrintWriter(outputStream);
InputReader in = new Input... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 1029c6291be7a8933d93d672c4f8f97a | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes |
import java.util.Scanner;
public class Main {
public static Scanner scammer = new Scanner(System.in);
public static int querry(int left, int right, boolean rite){
if(left == right)
return rite ? right + 1 : left - 1;
System.out.print("? ");
System.out.print(lef... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 291047f22d9dc6d9d2899aa6cc70d711 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
public class C1486 {
public static void main(String[] args) throws Exception {
int n = i();
out.println("? 1 " + n);
out.flush();
int sec = i();
int sectemp = 0;
if (sec!=1) {
out.println("? 1 " + sec);
out.flush();
sectemp = i();
}
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 557248660c5fbc25f0d45ecf0294e64d | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.Scanner;
public class Main {
private static Scanner cin;
private static int query(long l, long r) {
System.out.println("? " + l + " " + r);
System.out.flush();
return cin.nextInt();
}
public static void main(String[] args) {
cin = new Sc... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 74b06601c2225e5368c1d52d2e42a667 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class C2 {
public static boolean check(int l, int r, int v, BufferedReader in) throws IOException {
System.out.printf("? %d %d\n", l, r);
System.out.flush();
int ans = Integer.p... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 89d48627528862611e01fbdfc80bbf04 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
public class GuessingTheGreatest {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
System.out.println("? 1 " + N);
System.out.flush();
int m = in.nextInt();
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | e80579a377a7ac42348f0c1f17f2ad46 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
public class Solution {
private static boolean TESTS = false;
private final Input in;
private final PrintStream out;
public Solution(final Input in, final PrintStream out) {
this.in = in;
this.out = out;
}
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 4d81aa830db8940966cf735db34042b8 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTas... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 9a5fcb9c6e651d12887f867ebdb4a11e | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
/*
HashMap<> map=new HashMap<>();
TreeMap<> map=new TreeMap<>();
map.put(p,map.getOrDefault(p,0)+1);
for(Map.Entry<> mx:map.entrySet()){
int v=mx.getValue(),k=mx.getKey();
}
ArrayList<Pair<Char... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 6cbd6e2ffc97a83dd117d5059707314c | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
public class Main {
static Scanner in = new Scanner(System.in);
// static Scanner in = new Scanner( new File("javain.txt"));
public s... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 7cfc155444160d37edeff915b7a79116 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Formatter;
import java.util.Random;
/**
* Coder: SumitRaut
* Date: 27-02-2021 14:23
*/
public class Main {
public static void main(Stri... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | b639401edafe3b2305c2543d82b8df91 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Stack;
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 847fd622269b60a5e99b73537a0a203d | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Stack;
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 3a231cd6f018b7bc00596939a45e29e5 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 8fd1f9a28d31f37970872342a2e632a0 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.TimeUnit;
public class c1486 implements Runnable{
public static void main(String[] args) {
try{
new Thread(null, new c1486(), "process", 1<<26).start();
}
catch(Exception e){
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | d258806a1e45da77a550cc81fe225011 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class C {
static int ans = Integer.MAX_VALUE;
static String str = "";
static int[] dp;
public static void main(String[] args) throws IOException {
FastScanner fs=new FastScanner();
PrintWriter out = new PrintWriter(System.... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | bb7ac74d626446a6d55acc85ae29cc9f | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
/**
* @author Mubtasim Shahriar
*/
public class Cr703A {
public static void main(String[] args) {
InputStream inputStream = S... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | eeab329588d304902cff37d589216d4f | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
/**
*
* @Har_Har_Mahadev
*/
public class C {
private static long INF = 2000000000000000000L, M = 1000000007, MM = 998244353;
private static int N = 0;
public static void process() throws IOException {
int n = sc.nextInt();
int sma... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | b6d0c8572307c97e3f6209edda33de01 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
static FastScanner fs;
public static void main(String[] args) {
fs=new FastScanner();
// int t = fs.nextInt();
// while (t-->0)
solve();
}
public static void solve() {
int n = fs.nextInt();
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 6fc7c1b6053c2e665759c8a9d04e0b02 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.PrintWriter;
public class T1698C2 {
private static final T1698C2FastScanner in = new T1698C2FastScanner();
private static final PrintWriter out = new PrintWriter(System.out);
public static void main(St... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 5924016a5ba4587614726868d1dcf676 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class guessing {
//--------------------------INPUT READER--------------------------------//
static class fs {
public BufferedReader br;
StringTokenizer st = new StringTokenizer("");
public fs() { this(System.in); }
public f... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 8fd04f4af5e93a638bdfa64f1b817170 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.Scanner;
public class Main {
private static Scanner cin;
private static int query(long l, long r) {
System.out.println("? " + l + " " + r);
System.out.flush();
return cin.nextInt();
}
public static void main(String[] args) {
cin = new Scann... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 176f8b90ad36af005506572bd67e1604 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | /**
* BaZ :D
*/
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main
{
static MyScanner scan;
static PrintWriter pw;
static long MOD = 1_000_000_007;
static long INF = 2_000_000_000_000_000_000L;
static long inf = 2_000_000_000;
public stat... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 82e205f1be1f80e34d7e423e6b41fe1b | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 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.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
im... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | f87eace5b79aa90585a41174b0b8346c | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
// import java.math.BigInteger;
import java.util.*;
public class Solution {
public static void main(String[] args) {
int n = in.nextInt(), ... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 36e8b54563440960e8c20b69d67e1eb1 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | /*******************************************************************************
* author : dante1
* created : 18/02/2021 23:12
*******************************************************************************/
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
impo... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 5e0e787a185bdeda36c9051f87816d04 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static PrintWriter pw;
static Scanner sc;
static long ceildiv(long x, long y) { return (x+y-1)/y; }
static int mod(long x, int m) { return (int)((x%m+m)%m); }
static void put(HashMap<Integer, Integer> map, Integer p){if(map.containsK... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 351be300840a15eba3497af2014ad011 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
public class Main{
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputSt... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 6ffab90b3b8d86dd2e2d038619a8754b | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | //I AM THE CREED
/* //I AM THE CREED
/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
import java.awt.Point;
public class Main{
static final Random ran... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 751cc5c451ef0caa353d838bc368e1b5 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class cf {
static PrintWriter pw = new PrintWriter(System.out);
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) throws IOException, InterruptedException {
int n = sc.nextInt();
pw.println("! " + bs(n))... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | b9092b24e831e5348dabdb379c163dc0 | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | //package R703;
import java.io.*;
import java.math.*;
import java.util.*;
public class Q3 {
static int INF = (int)(1e9);
static long mod = (long)(1e9)+7;
static long mod2 = 998244353;
static long[] segtree;
static char[] curans;
static long ans;
static String S;
static ArrayList<Integer>[] graph;
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 3f3cc3be50b217b07613aa491f3e49fb | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | c82a851515c000f7a86e5588542588fc | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.util.*;
public class C {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next() {
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 276bad82bc3841c5b572fba0fba5d2bd | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class TaskA {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
Task solver = new Task();
solver.solve(in, out);
... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output | |
PASSED | 0656dd5fa58316a027434d6e87d864df | train_109.jsonl | 1613658900 | The only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array $$$a$$$ of $$$n$$$ different numbers. In one query you can ask the position of the second maximum element in a subsegment $$$a[l..r]$$$. Find the position of the maximum eleme... | 256 megabytes | import java.util.Scanner;
public class C1486 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
System.out.println("? 1 " + N);
System.out.flush();
int second = in.nextInt();
int low = -1;
int hig... | Java | ["5\n\n3\n\n4"] | 1 second | ["? 1 5\n\n? 4 5\n\n! 1"] | NoteIn the sample suppose $$$a$$$ is $$$[5, 1, 4, 2, 3]$$$. So after asking the $$$[1..5]$$$ subsegment $$$4$$$ is second to max value, and it's position is $$$3$$$. After asking the $$$[4..5]$$$ subsegment $$$2$$$ is second to max value and it's position in the whole array is $$$4$$$.Note that there are other arrays $... | Java 8 | standard input | [
"binary search",
"interactive"
] | eb660c470760117dfd0b95acc10eee3b | The first line contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$ — the number of elements in the array. | 1,900 | null | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.