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
c9aa6ff1a54fb5e670328b11e2df4930
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" ]
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
010c6fbbdf4f4cc40bb82699b319860d
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.CountDownLatch; // import javax.lang.model.element.QualifiedNameable; // import javax.swing.ViewportLayout; // import javax.swing.plaf.basic.BasicTreeUI.TreeCancelEditingAction; // import javax.swing.plaf.metal.MetalComboBoxUI.MetalPropertyChangeListener; // 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
0a5fece048154fd9c41d2681e851c032
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.HashMap; import java.util.HashSet; import java.util.Random; import java.util.Stack; import java.util.StringTokenizer; ...
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
9af93967053aff08f2ec32cc97aa9d03
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" ]
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
f1522b964b01e447561090fe641335e1
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.math.BigInteger; //import javafx.util.*; public final class B { static StringBuilder ans=new StringBuilder(); static FastReader in=new FastReader(); static ArrayList<ArrayList<Integer>> g; static long mod=1000000007; static 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
94dca4f4ac55ffd66fc3cf33827afc7c
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 { 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" ]
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
79ea6f6fc6ea6383cb9167d08fc8d06f
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(); out.println...
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
6626732f719194fa20c3832a4934b4b9
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.lang.reflect.Array; import java.text.DecimalFormat; import java.util.*; import java.io.*; public class Equal { static class pair implements Comparable<pair> { int x; int y; public pair(int u, int v) { this.x = u; this.y = 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" ]
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
67690286a36634f083b021b769d144bd
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 Scanner sc = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); // long mod = 998244353; // long mod = (long)1e9...
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
76fd9d43f5decff608b51a611aac0208
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; import static java.lang.Double.parseDouble; import static java.lang.Integer.compare; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.System.in; public class Main { private static final int MOD =...
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
df18c9416bbde5a06cd757fdab97b6fa
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.util.InputMismatchException; import java.util.*; import java.io.*; import java.lang.*; public class Main{ public static class InputReader { private InputStream strea...
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
227f67719df07e1eae2dc733a47c55c8
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" ]
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
99979edb06719b8f97bb99811b4eac8f
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" ]
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
7202fc148ce102afa753ac40a20a92b5
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 guessingthegreatesteasy { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(f.readLine()); int n = Integer.parseInt(st.nextToken());...
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
b59d48e856674851ad72da3fb5c59a4c
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.*; public class Practice { public static void main(String[] args) throws Exception { Scanner s = new Scanner(System.in); int n = s.nextInt(); System.out.flush(); getAns(n, s); } pr...
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
e401a4b9a137c543d7f634bfc649faba
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.*; /* polyakoff */ public class Main { static FastReader in; static PrintWriter out; static Random rand = new Random(); static final int oo = (int) 1e9 + 10; static final long OO = (long) 2e18 + 10; static final int MOD = (int) 1e9 + 7; ...
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
b052870c39aadff5e6e3457386c4f30b
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.awt.*; public class C { BufferedReader in; PrintWriter ob; StringTokenizer st; public static void main(String[] args) throws IOException { new C().run(); } void run() throws IOException { in=new BufferedReader(new ...
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
714c899693470612772cccc79242dbb1
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 C { static Scanner sc = new Scanner(System.in); public static long ask(long l, long r) { if(l >= r) return -1; System.out.println("? " + l + " " + r); long x = sc.nextLong(); return x; } public static void main(String[] args) { long n = 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
486d4e9deb7d0f1605474a065f19bcca
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 C { public static void main(String[] args) { FastScanner fs = new FastScanner(); int t = 1;//fs.nextInt(); while (t-- > 0) { 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
0f09c47526c46bd33122723eba1e8b69
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" ]
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
3ac47936f07e3052791133c76ce4b9fe
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
// 18-Feb-2021 import java.util.*; import java.io.*; public class C { static class FastReader { BufferedReader br; StringTokenizer st; private FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { ...
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
ae91dde692f5296d1efc11246598a674
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" ]
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
5bd8c0f96c8931838309238e1ce0ae9d
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.awt.*; import java.io.*; import java.lang.reflect.Array; import java.util.*; import java.util.List; import java.util.concurrent.LinkedBlockingQueue; public class Coding { private static BufferedReader bi = new BufferedReader(new InputStreamReader(System.in)); private static BufferedW...
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
c176b6a1e45dd0ee639ab68d4ae5ee91
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 FastScanner sc = new FastScanner(System.in); static PrintWriter pw = new PrintWriter(System.out); static StringBuilder sb = new StringBuilder(); public static void main(String[] args) throws Exception { int n = sc.nextIn...
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
342076fe85ede31ba9c01d6a5ccd3846
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.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class GuessingTheGreatest implements Closeable { private InputReader in = new InputReade...
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
c9d3127cc0055b58335f4646bdb4570d
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" ]
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
55f6470a0f38ee49d6fd0ea3e57f94dd
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.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static...
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
6a3a1925f3afe3f4684f25192b25a298
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.StringTokenizer; public class C { public int ask(IO io, int l, int r) throws IOException { if (l == r) { return r + 1; } io.println("? " + l + " " + r); io.flush(); re...
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
28ae890820894e0f83286170bd2d7e07
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
//created by Whiplash99 import java.io.*; import java.util.*; public class C { private static int count; private static void flush(){System.out.flush();} private static void ask(int l, int r) throws Exception { count++; if(count>20) throw new Exception(); System.out.println("? ...
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
3aa28bb65599992fc7df0820f2f1affb
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" ]
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
84e179ef2f7a73eab6aa261e33d7777c
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) { FastScanner in = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int low = 1, high = n; out.println("? "+low+" "+high); out.flush()...
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
b7054454051ca20e0c4508c9f6670854
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.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.List; import java.util.*; public class realfast implements Runnable { private static final int INF = (int) 1e9; // long in= 1000000007; long fac[]= new long[1000001]; ...
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
46f8080a42715db7cf73d6461aee3869
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" ]
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
91e2b82ff4e48c9a4b827ad184951e6a
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 EdA { static long[] mods = {1000000007, 998244353, 1000000009}; static long mod = mods[0]; public static MyScanner sc; public static PrintWriter out; public static void main(String[] omkar) throws Exception{ // TODO Auto-generated method stub 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
94a747d05278e11bcdea1ff26f4139e3
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" ]
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
53c5e887c6d83c435cd1a0a0e688b3c1
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" ]
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
d3dacf9f6d87e8ebac68010b5ad887cc
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" ]
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
d3bc4a52008d4a5f2ec21184dfcd4a05
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 Div708 { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////...
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
bb8a7340bcbb119ad429238c03456c39
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" ]
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
38b2c036c795f87d7b0807896c16b000
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 C_1486 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); pw.printf("? 1 %d\n", n); pw.flush(); int max2 = sc.nextInt(); if(...
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
f47491750ea38cf7594341a93f6d0c17
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 F { static int query(int l, int r) throws IOException { System.out.printf("? %d %d\n", l, r); return sc.nextInt(); } static Scanner sc = new Scanner(); public static void main(String[] args) throws IOException { int n = sc.nextInt(); 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
9cc0b248a9a08710b866e564dfa468cb
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 Solve{ static Scanner sc=new Scanner(System.in); public static void main(String[] args){ int n=sc.nextInt(); int l=0; int r=n-1; int sec=q(l+1,r+1); if(q(l+1,sec+1)!=sec || sec==0) { // right ...
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 11
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
48c7e6e83a72fea32415c3a102b2796f
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 Solve{ static Scanner sc=new Scanner(System.in); public static void main(String[] args){ int n=sc.nextInt(); int l=0; int r=n-1; int sec=q(l+1,r+1); if(q(l+1,sec+1)!=sec || sec==0) { l=se...
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 11
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
44556f972f048f5c237561bab6626f69
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 int right(int max,int start,int end,int n) { FastScanner f = new FastScanner(); if(end<start) { return 1000000000; } else { int mid=(start+end)/2; System.out.println("? "+(max+1)+" "+(mid+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 11
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
0af7ca6c92fa2ba94940385b7ae8d847
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 int right(int max,int start,int end,int n) { FastScanner f = new FastScanner(); if(end<start) { return 1000000000; } else { int mid=(start+end)/2; System.out.println("? "+(max+1)+" "+(mid+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 11
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
c21cc507ec5d29f24733a3b36202bf3a
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 int right(int max,int start,int end,int n) { FastScanner f = new FastScanner(); if(end<start) { return n-1; } else { int mid=(start+end)/2; System.out.println("? "+(max+1)+" "+(mid+1)); int place=...
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 11
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
65c073bd159736bd271ed480686a826b
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 CF { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { 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 11
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
278dfbbceca5bb020214fb66782d73ff
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 CF { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { 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 11
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
f4953807e72a6362f3f11471f9a9f0ed
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.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { long mod1 = (long) 1e9 + 7; int mod2 = 998244353; public void solve() throws Exception { int n=sc.nextInt(); int start=1; int end...
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 11
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
62163abea677b58aa629533d9f04512f
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.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { long mod1 = (long) 1e9 + 7; int mod2 = 998244353; public void solve() throws Exception { int n=sc.nextInt(); int start=1; int end...
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 11
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
1c0685ee7841dd9aa69b983e753bdcb7
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.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { long mod1 = (long) 1e9 + 7; int mod2 = 998244353; public void solve() throws Exception { int n=sc.nextInt(); int start=1; int end...
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 11
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
1ef7ff5d0062050777f1c642dfa9c41e
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.InputMismatchException; /** * Created by Wilson on * Feb. 08, 2021 */ public class HardMaxelementInteractive { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader...
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 11
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
f3d243d60829e52d93f113d7de13f0b6
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.InputMismatchException; /** * Created by Wilson on * Feb. 08, 2021 */ public class HardMaxelementInteractive { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader...
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 11
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
c7a3521fb17ae796920708b5b8e0de04
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.ArrayList; import java.util.Arrays.*; import static java.util.Collections.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf { static final int SCAN_LINE_LENGTH = 100002; private static final boolean thread = fal...
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 11
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
bd083abd3cc55978ef6d25985841a286
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 D { static class pair implements Comparable<pair> { int f; int s; double th; int id; public pair() { } public pair(int a, int b, int c) { f = a; s = b; th = (f * 1.00000) / (s * 1.00000); id = c; } @Overrid...
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 11
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
578ffe72772b0bc07ad3decea248b234
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.PrintStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.Writer; ...
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 11
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
18d24cf15a7c7c9657eb8278c9b3f6f1
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 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 Template { public static void main(String[] args) throws Exception{ BufferedReader infile = new BufferedReader(new InputStreamReade...
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 11
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
cc04fde564a68607817d3d9398fd6239
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 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 Template { public static void main(String[] args) throws Exception{ BufferedReader infile = new BufferedReader(new InputStreamReade...
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 11
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
31dda17ff565bc6bde6c603fb7e38deb
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.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Arrays; import java.util.Random; import java.io.FileWriter; import java.io.PrintWriter; /* Solution Created: 19:43:18 18/02/2021 C...
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 11
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
626161a2cf0dbc556602229d4a8e92ee
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.awt.*; import java.io.*; import java.util.*; import java.util.List; public class Hell { public static void main(String[] args) throws Exception { FastReader sc = new FastReader(); int n=sc.nextInt(); System.out.println("? 1 "+n); System.out.flush(); 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 11
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
b89bcd2c6131f19217c4762746a623a6
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.HashMap; import java.util.HashSet; import java.util.Random; import java.util.Stack; import java.util.StringTokenizer; ...
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 11
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
786a8ea4dc2913466f380e5e45b70231
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 Codeforces { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //int cases = Integer.parseInt(br.readLine()); //o:while(cases-- > 0) { String[] str = br.readLine().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 11
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
3a4ac6df4d35c6d94daaa8e1b43d7415
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.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.Map; import java.util.TreeMap; public class Main { private static void run() throws IOException { 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 11
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
2da146aef2fe1ac1b76d4b98d7005856
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.*; @SuppressWarnings("unchecked") public class GuessingTheGreatestHard implements Runnable { void solve() throws IOException { int l = 1, h = read.intNext(); int dmax = ask(l, h); if (ask(l, dmax) == dmax) { h = dmax; ...
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 11
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
07f5fcd77f5ad1f37d35d530924ff0cb
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 { public static class FastIO { BufferedReader br; BufferedWriter bw, be; StringTokenizer st; public FastIO() { br = new BufferedReader(new InputStreamReader(System.in)); bw = new BufferedWriter(new OutputStreamWriter(System.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 11
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
78512d563b13354ac83aa58e285c9fc6
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 static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.io.*; import java.util.*; public class B { static int n; static int[] arr; static char[] s; public static void main(String[] args) throws IOException { f = new Flas...
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 11
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
56792dbec1d9d5217b8b4a8a7b30a43e
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 cf { static Reader sc = new Reader(); // static Scanner sc = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) { int n = sc.nextInt(); int ans = -1; int index = query(1, n); if...
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 11
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
489c8a9ee001a1f90d7a7160e4db2131
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.Arrays; import java.util.Random; import java.util.StringTokenizer; public final class C { public static void main(String[] args) { final FastScanner fs = new FastScanner(); ...
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 11
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
6a6aa473b68ecb135f8cd6de7c6263ff
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.Arrays; import java.util.Random; import java.util.StringTokenizer; public final class C1 { public static void main(String[] args) { final FastScanner fs = new FastScanner(); ...
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 11
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
4dd362e68aaaf512ce74ff315d1c794f
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 Solution{ public static void main(String[] args) { TaskA solver = new TaskA(); // int t = in.nextInt(); // for (int i = 1; i <= t ; i++) { // solver.solve(i, in, out); // } solver.solve...
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 11
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
f2b017bd4d6000e0be09525df5b0fbf5
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.*; public class Main { public static int[] a = new int[]{0, 4, 3, 2, 1, 5}; public static void main(String[] args) throws Exception{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int testCase = Integer.parseInt(in.readLine().trim()); int l = 1; int 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 11
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
4c8b93b0877a77391d74ea47d9912a76
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 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(String s) { try { br = new BufferedReader(new FileReader(s)); } catch (FileNotFoundException...
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 11
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
034b06b58dd0ac9ba2a6caeee50ac6d6
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.StringTokenizer; public class C { void solve() throws IOException { int n = nextInt(); int begin = 1; int end = n; /* 5 1 3 4 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 11
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
d6ffb983be6e26cb0d1e0474db26706e
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.*; public class CodeForces { public static void main(String[] args) { // TODO Auto-generated method stub FastScanner fs=new FastScanner(); int n=fs.nextInt(); int pos=solve(n); Syst...
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 11
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
62098d7f6649049ae99a01475f85f6f4
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
// c1 import java.util.*; // import java.lang.*; import java.io.*; // THIS TEMPLATE MADE BY AKSH BANSAL. public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStrea...
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 11
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
99c47dc4a57585d46d7081ee4841c137
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 Q1486C { static Scanner s = new Scanner(System.in); public static void main(String args[]) { int r = s.nextInt(); System.out.println("? 1 " + r); System.out.flush(); int k = s.nextInt(); if(r==2) { System.out.println("! " + (3-k)); 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 11
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
045aeed6392a7eaeba45774544f7c5c8
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 GuessingTheGreatest2 { static FastScanner fs; static FastWriter fw; static boolean checkOnlineJudge = System.getProperty("ONLINE_JUDGE") == null; private static final int iMax = (int) (1e9), iMin = (int) (-1e9); private static final lon...
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 11
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
880fa225b71690a8d64c7f5215a9d1c5
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
/* TO LEARN 2-euler tour */ /* TO SOLVE codeforces 722 kavi on pairing duty */ /* ...
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 11
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
dc9938aa6b7b91356b061aa85ec25da3
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
//https://codeforces.com/contest/1486/problem/C2 //C2. Guessing the Greatest (hard version) import java.util.*; import java.io.*; public class CF_1486_C2{ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.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 11
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
0293554d38b5805c08a841e21596d726
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
/*input */ import java.util.*; import java.lang.*; import java.io.*; public class Main { static PrintWriter out; static int MOD = 1000000007; static FastReader scan; /*-------- I/O using short named function ---------*/ public static String ns(){return scan.next();} public static int ni(){retur...
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 11
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
ee39c86d4a1355d5e628d2d2fd8b1070
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 { BufferedReader Rb = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.valueOf(Rb.readLine()); int l = 1, r = n; System.out.println("? " + 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 11
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
9c615e36ba3f6135a956c80322a3a0b3
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 GuessingTheGreatestHard { static FastScanner fs = new FastScanner(); static int query(int left, int right) { System.out.println("? " + left + " " + righ...
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 11
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
06aaefedf0ab46f8a1ecf1d8b95f0184
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; ...
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 11
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
fa886e682a579512869f47c28ca75a56
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 Solution { static Reader input; public static void main(String[] args) throws IOException { input = new Reader(); int n = input.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 11
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
4be74713a3a09e5566a712f754dcd408
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.lang.*; public class cf719 { public static int query(int l,int r) throws Exception{ if(l>=r)return -1; InputStreamReader ip=new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ip); Syst...
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 11
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
cfb2527a128e02373c62ca80ddaf87ff
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.lang.*; public class cf719 { public static int query(int l,int r) throws Exception{ if(l>=r)return -1; InputStreamReader ip=new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ip); Syst...
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 11
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
3d89019bec7646237b7ed3cf73055123
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 D { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int mid = ask(1, n, sc); if (mid < n && ask(mid, n, sc) == mid) { solve(mid, n, false, sc, mid); } else { solve(1, mid, true, sc, mid); } } ...
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 11
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
e06562fa1e915b201b735a54ffc876ee
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.*; public class Main { static class DisjointUnionSets { int[] rank, parent; int n; // Constructor public DisjointUnionSets(int n) { 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 11
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
8fba1039c9eccaa33fe71b3cac378871
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; public class C2_Rnd703_Div2 { static int n; public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader scan = new BufferedReader(new InputStrea...
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 11
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
a8e79cf35441397f7e59bb38802cef69
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.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.io.*; import java.util.*; public class CFEd { public static void main(String[] args) { Scanner us = new Scanner(System.in); int n = us.nextInt(); ask(1, n); int re...
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 11
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
b003e7e51359aa907fd0a33a55ff3b01
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 tank { //static StringBuilder IO = new StringBuilder(); //static final Scanner scan = new Scanner(System.in); static final FastScanner fs = new FastScanner(); public static void main(String[] args) { // int t = 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 11
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
f06170ea3badab724a5648976d47a03c
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 Index { static Scanner scan = new Scanner(System.in); static int query(int l, int r) { if(l>=r)return 0; System.out.printf("? %d %d\n", l, r); System.out.flush(); return scan.nextInt(); } 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 11
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
34b21000f7c478f4520c3c8da2608be0
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 void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); System.out.println("? 1 "+n); System.out.flush(); int x=sc.nextInt(); boolean f=false; if (x!=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 11
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
fbf599dbfcacc1a1ab7eaa02158c974c
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.*; //My life seems to be a joke. But, one day I will conquer. public class B{ public static Scanner sc = new Scanner(System.in); public static int query(int l, int r) { if(l>=r)return -1; System.out.println("? "+l+" "+r); int a = sc.nextInt(); return a; } 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 11
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
5706ccef4ac2d203215fc656bed96eb9
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 Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int scan()thro...
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 11
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
8c6e20e0b7a3d6fca28df6a3d410d715
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 Solution{ public static void main(String[] args) { TaskA solver = new TaskA(); // int t = in.nextInt(); // for (int i = 1; i <= t ; i++) { // solver.solve(i, in, out); // } solver.solve...
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 11
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
ed1f8929d3f8468ca750027982e162ef
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
/* "Everything in the universe is balanced. Every disappointment you face in life will be balanced by something good for you! Keep going, never give up." Just have Patience + 1... */ import java.util.*; import java.lang.*...
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 11
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
497e598cd8560d002e7357b9bd19ba1f
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.Random; import java.util.StringTokenizer; public class Solution { static ArrayList<String> list; public static ...
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 11
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
328378c45afc83312e2ebc6183bc634d
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 { void solve() { int n = in.nextInt(); int low = 1; int high = n; int secondLast = query(1, n); if (secondLast == 1) { low = 2; } else if (secondLast == 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 11
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
8cbada4c6d2e0e7fc686fcecaaa2ecf3
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.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.Map; import java.util.TreeMap; public class Main { private static void run() throws IOException { 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 11
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