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
ecb58fe7021bb27b48dbadaa764c976b
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main { public static void main(String[] args) throws IOException { //System.out.println("Hello World"); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(in.readLine()); for(int p=0; p<t; p+...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
07c68607f466952e763fe04b2d1558c6
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
import java.util.Scanner; public class Main { public static Scanner scanner=new Scanner(System.in); public static void main(String[] args) { int t=scanner.nextInt(); int n,m,k,d; while(t--!=0){ n=scanner.nextInt(); m=scanner.nextInt(); k=scanner.nextInt(); ...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
66e58f8981e8e02451e511b811abae12
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Minimise { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new Input...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
1b8606938ffd460da2d2c9226a4e4b2d
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class BerlandPoker { InputStream is; PrintWriter pw; String INPUT = ""; long L_INF = (1L << 60L); void s...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
b42b46b43a0e28d484b6bdf31a5fcec9
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static void main(String []args)throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out)); int t=Integer.parseInt(br.read...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
c5d7369cd4616280bbed1daf6064ef89
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
//package cp; import java.util.*; public class Cf { public static void main(String[] args) { int t; Scanner sc=new Scanner(System.in); t=sc.nextInt(); for(int i=0;i<t;i++) { int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt(); if(m/(n/k)==0) System.out.println(m); else if(k==2) { System.out.println((2*n/k)-m); } els...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
7499b7740a332b327de5e56f3f1d3341
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ static boolean[] sieve(int n){ boolean[] ret=new boolean[n+1]; Arrays.fill(ret,true); for(int i=0;i<=n;i++)ret[i]=true; for(int i=2;i*i<=n;i++){ if(ret[i]==false)continue; for(int j=i*i;j<=n;j+=i){ ret[j]=false; } } return ret; } s...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
fa117c953c6b4d655df99980d00936db
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
import java.util.*; public class solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++) { int n=sc.nextInt(); int m=sc.nextInt(); int k=sc.nextInt(); if(m==0) { System.out.println(0); } else { int x=n/k; if(...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
5c103010e89cca689b84c72003d49049
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class codeforces4 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() ...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
3f7e8d26cb95742ece7a33308fbcee00
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); scanner.nextLine(); for(int i = 0; i < n; i++) { int totalCards = scanner.n...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
0ce9b7bec96720e19b56f5db9ba95827
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
import java.io.*; import java.lang.String; import java.util.*; public class Main { private static int BinarySearch(int a[], int low, int high, int target) { if (low > high) return -1; int mid = low + (high - low) / 2; if (a[mid] == target) return mid; if (a[...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
a8b143dcf7b767daed2cc4741ae9f086
train_003.jsonl
1590676500
The game of Berland poker is played with a deck of $$$n$$$ cards, $$$m$$$ of which are jokers. $$$k$$$ players play this game ($$$n$$$ is divisible by $$$k$$$).At the beginning of the game, each player takes $$$\frac{n}{k}$$$ cards from the deck (so each card is taken by exactly one player). The player who has the maxi...
256 megabytes
import java.util.Scanner; public class BerlandPoker { public static void main(String[] args) { // read the input Scanner scanner = new Scanner(System.in); int t = Integer.parseInt(scanner.nextLine()); for(int i=0; i<t; i++){ String[] input = scanner.nextLine().split(" ")...
Java
["4\n8 3 2\n4 2 4\n9 6 3\n42 0 7"]
2 seconds
["3\n0\n1\n0"]
NoteTest cases of the example are described in the statement.
Java 11
standard input
[ "greedy", "math", "brute force" ]
6324ca46b6f072f8952d2619cb4f73e6
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Then the test cases follow. Each test case contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n \le 50$$$, $$$0 \le m \le n$$$, $$$2 \le k \le n$$$, $$$k$$$ is a divisors of $$$n$$$).
1,000
For each test case, print one integer — the maximum number of points a player can get for winning the game.
standard output
PASSED
3fe7fa73c1de6111a7a627b653f70d31
train_003.jsonl
1503068700
Lech got into a tree consisting of n vertices with a root in vertex number 1. At each vertex i written integer ai. He will not get out until he answers q queries of the form u v. Answer for the query is maximal value among all vertices i on path from u to v including u and v, where dist(i, v) is number of edges on pat...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.io.BufferedReader; impo...
Java
["5 3\n0 3 2 1 4\n1 2\n2 3\n3 4\n3 5\n1 4\n1 5\n2 4", "5 4\n1 2 3 4 5\n1 2\n2 3\n3 4\n4 5\n1 5\n2 5\n1 4\n3 3"]
3 seconds
["3\n4\n3", "5\n5\n4\n3"]
null
Java 8
standard input
[ "trees" ]
58310c2326a4c436df94a41c5c906eb6
First line of input data contains two integers n and q (1 ≤ n ≤ 5·104, 1 ≤ q ≤ 150 000) — number of vertices in the tree and number of queries respectively. Next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ n) — numbers on vertices. Each of next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n) — descripti...
3,200
Output q lines — answers for a queries.
standard output
PASSED
9aac31a2fba720a0c4a9493f289be03d
train_003.jsonl
1503068700
Lech got into a tree consisting of n vertices with a root in vertex number 1. At each vertex i written integer ai. He will not get out until he answers q queries of the form u v. Answer for the query is maximal value among all vertices i on path from u to v including u and v, where dist(i, v) is number of edges on pat...
256 megabytes
import java.io.*; import java.util.*; public class E { int[] a; static final int LOG = 8; static final int BLOCK = 1 << LOG; static final int LOW_MASK = BLOCK - 1; int[] head; int[] next; int[] to; int[] par; int[] depth; void dfs(int v, int p) { par[v] = p; for (int e = head[v]; e >= 0; e = next[e]...
Java
["5 3\n0 3 2 1 4\n1 2\n2 3\n3 4\n3 5\n1 4\n1 5\n2 4", "5 4\n1 2 3 4 5\n1 2\n2 3\n3 4\n4 5\n1 5\n2 5\n1 4\n3 3"]
3 seconds
["3\n4\n3", "5\n5\n4\n3"]
null
Java 8
standard input
[ "trees" ]
58310c2326a4c436df94a41c5c906eb6
First line of input data contains two integers n and q (1 ≤ n ≤ 5·104, 1 ≤ q ≤ 150 000) — number of vertices in the tree and number of queries respectively. Next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ n) — numbers on vertices. Each of next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n) — descripti...
3,200
Output q lines — answers for a queries.
standard output
PASSED
9b29a828970fe5bf3fa3a15f6b901469
train_003.jsonl
1503068700
Lech got into a tree consisting of n vertices with a root in vertex number 1. At each vertex i written integer ai. He will not get out until he answers q queries of the form u v. Answer for the query is maximal value among all vertices i on path from u to v including u and v, where dist(i, v) is number of edges on pat...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Div1_429E { static int nV; static int[] vals = new int[5...
Java
["5 3\n0 3 2 1 4\n1 2\n2 3\n3 4\n3 5\n1 4\n1 5\n2 4", "5 4\n1 2 3 4 5\n1 2\n2 3\n3 4\n4 5\n1 5\n2 5\n1 4\n3 3"]
3 seconds
["3\n4\n3", "5\n5\n4\n3"]
null
Java 8
standard input
[ "trees" ]
58310c2326a4c436df94a41c5c906eb6
First line of input data contains two integers n and q (1 ≤ n ≤ 5·104, 1 ≤ q ≤ 150 000) — number of vertices in the tree and number of queries respectively. Next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ n) — numbers on vertices. Each of next n - 1 lines contains two integers u and v (1 ≤ u, v ≤ n) — descripti...
3,200
Output q lines — answers for a queries.
standard output
PASSED
2fad8f597b823474dbd3b37d20c7c7b6
train_003.jsonl
1588775700
Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,...
256 megabytes
/*package whatever //do not write package name here */ import java.io.*; import java.util.*; public class S { public static void main (String[] args) { Scanner in=new Scanner(System.in); int t=in.nextInt(); while(t--!=0) { int n=in.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++)a[i]=in.n...
Java
["6\n1\n14\n2\n1 -1\n4\n5 5 5 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11"]
1 second
["YES\nYES\nYES\nNO\nNO\nYES"]
NoteIn the first test case, every guest is shifted by $$$14$$$ rooms, so the assignment is still unique.In the second test case, even guests move to the right by $$$1$$$ room, and odd guests move to the left by $$$1$$$ room. We can show that the assignment is still unique.In the third test case, every fourth guest move...
Java 8
standard input
[ "sortings", "math" ]
2173310623173d761b6039f0e5e661a8
Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. Next $$$2t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 2\cdot 10^5$$$) — the length of the arra...
1,600
For each test case, output a single line containing "YES" if there is exactly one guest assigned to each room after the shuffling process, or "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
b293392400f7532b8fd87a49ff667c00
train_003.jsonl
1270136700
String s of length n is called k-palindrome, if it is a palindrome itself, and its prefix and suffix of length are (k - 1)-palindromes. By definition, any string (even empty) is 0-palindrome.Let's call the palindrome degree of string s such a maximum number k, for which s is k-palindrome. For example, "abaaba" has deg...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class PalindromeDegree { static final long B = 33; static final long C = 127; public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["a2A", "abacaba"]
1 second
["1", "6"]
null
Java 7
standard input
[ "hashing", "strings" ]
0090979443c294ef6aed7cd09201c9ef
The first line of the input data contains a non-empty string, consisting of Latin letters and digits. The length of the string does not exceed 5·106. The string is case-sensitive.
2,200
Output the only number — the sum of the polindrome degrees of all the string's prefixes.
standard output
PASSED
49693f9c477d0723c68900932edb36ed
train_003.jsonl
1270136700
String s of length n is called k-palindrome, if it is a palindrome itself, and its prefix and suffix of length are (k - 1)-palindromes. By definition, any string (even empty) is 0-palindrome.Let's call the palindrome degree of string s such a maximum number k, for which s is k-palindrome. For example, "abaaba" has deg...
256 megabytes
import java.io.*; import java.util.StringTokenizer; /** * CodeForces Round 7D - Palindrome Degree * Created by Darren on 14-9-26. */ public class Main { Reader in = new Reader(System.in); PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) throws IOException { ...
Java
["a2A", "abacaba"]
1 second
["1", "6"]
null
Java 7
standard input
[ "hashing", "strings" ]
0090979443c294ef6aed7cd09201c9ef
The first line of the input data contains a non-empty string, consisting of Latin letters and digits. The length of the string does not exceed 5·106. The string is case-sensitive.
2,200
Output the only number — the sum of the polindrome degrees of all the string's prefixes.
standard output
PASSED
93c5323242823a53f2382cea2580cb37
train_003.jsonl
1270136700
String s of length n is called k-palindrome, if it is a palindrome itself, and its prefix and suffix of length are (k - 1)-palindromes. By definition, any string (even empty) is 0-palindrome.Let's call the palindrome degree of string s such a maximum number k, for which s is k-palindrome. For example, "abaaba" has deg...
256 megabytes
//package hw5; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class ZAlgo { public static void main(String[] args) throws IOException { BufferedReader readInput = new BufferedReader(new InputStreamReader(System.in)); String str = readInput.readLine(); int n ...
Java
["a2A", "abacaba"]
1 second
["1", "6"]
null
Java 7
standard input
[ "hashing", "strings" ]
0090979443c294ef6aed7cd09201c9ef
The first line of the input data contains a non-empty string, consisting of Latin letters and digits. The length of the string does not exceed 5·106. The string is case-sensitive.
2,200
Output the only number — the sum of the polindrome degrees of all the string's prefixes.
standard output
PASSED
34f1ad3c77c32a2b53d890f5a3116fb5
train_003.jsonl
1270136700
String s of length n is called k-palindrome, if it is a palindrome itself, and its prefix and suffix of length are (k - 1)-palindromes. By definition, any string (even empty) is 0-palindrome.Let's call the palindrome degree of string s such a maximum number k, for which s is k-palindrome. For example, "abaaba" has deg...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class Palindrome { public static void main(String[] args) throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(Sy...
Java
["a2A", "abacaba"]
1 second
["1", "6"]
null
Java 7
standard input
[ "hashing", "strings" ]
0090979443c294ef6aed7cd09201c9ef
The first line of the input data contains a non-empty string, consisting of Latin letters and digits. The length of the string does not exceed 5·106. The string is case-sensitive.
2,200
Output the only number — the sum of the polindrome degrees of all the string's prefixes.
standard output
PASSED
60184205e3740bd9ee701ce3a4cee41c
train_003.jsonl
1270136700
String s of length n is called k-palindrome, if it is a palindrome itself, and its prefix and suffix of length are (k - 1)-palindromes. By definition, any string (even empty) is 0-palindrome.Let's call the palindrome degree of string s such a maximum number k, for which s is k-palindrome. For example, "abaaba" has deg...
256 megabytes
import java.io.*; import java.util.*; public class CF { // long mod = (long) 1e9 + 7; int[] pow; long mul = 53; int[] getHash(String s) { int n = s.length(); int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = (int) ((s.charAt(i) + (i == 0 ? 0 : mul * res[i - 1]))); } return res; } int...
Java
["a2A", "abacaba"]
1 second
["1", "6"]
null
Java 7
standard input
[ "hashing", "strings" ]
0090979443c294ef6aed7cd09201c9ef
The first line of the input data contains a non-empty string, consisting of Latin letters and digits. The length of the string does not exceed 5·106. The string is case-sensitive.
2,200
Output the only number — the sum of the polindrome degrees of all the string's prefixes.
standard output
PASSED
8616d2ab71928a2870f31c0354014d85
train_003.jsonl
1270136700
String s of length n is called k-palindrome, if it is a palindrome itself, and its prefix and suffix of length are (k - 1)-palindromes. By definition, any string (even empty) is 0-palindrome.Let's call the palindrome degree of string s such a maximum number k, for which s is k-palindrome. For example, "abaaba" has deg...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class cf7d { public static void main(String[] args) { F...
Java
["a2A", "abacaba"]
1 second
["1", "6"]
null
Java 7
standard input
[ "hashing", "strings" ]
0090979443c294ef6aed7cd09201c9ef
The first line of the input data contains a non-empty string, consisting of Latin letters and digits. The length of the string does not exceed 5·106. The string is case-sensitive.
2,200
Output the only number — the sum of the polindrome degrees of all the string's prefixes.
standard output
PASSED
93915723c81f8388cfdcda7fc68b71b2
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class MaxSeq { public static void main( final String[] args ) throws IOException { final BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) ); final String s = br.readLine(); System.out.p...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
954902070e8dbee533771f9d3a8eb9d5
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class two { public static void main(String[] args) throws IOException { BufferedReader buf = new BufferedReader( new InputStreamReader(System.in)); char[] c = buf.readLine().toChar...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
a740f3ac984d9e65b7ad693c681459f9
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class CF124C { public static void main(String[] args) throws IOException { char[] s = new BufferedReader(new InputStreamReader(System.in)) .readLine().trim().toCharArray(); StringBuilder ans = new StringBuilder...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
a4f4367b5f75d17ace4b4f8a3e296dae
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.*; import java.util.*; public class Main { BufferedReader br; int n, m; char c; String s; StringBuilder sb; public void go() throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); s = br.readLine(); sb = new StringBuilder(); c = '0'; for (in...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
9b98c50110234798c730a1c0448c9ba0
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.BufferedInputStream; import java.io.IOException; import java.util.Scanner; public class C197 { public static void main(String[] args) throws IOException { solve(); } public static void solve()throws IOException{ Scanner scan = new Scanner(new BufferedInputStream(System.in)); char sq[] = scan...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
b2ff34e059dcaa6f2e3a95afdc4802c0
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.*; import java.text.*; import java.io.BufferedReader;import java.math.*; import java.util.regex.*; import java.awt.geom.*; import static java.lang.Math.*; import static java.lang.Character.*; import static java.lang.Integer.*; import static java.lang.Double.*; import static java.lang.Long.*; import sta...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
6a2d1bcbd76766f70f1b554df135d3ec
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.Scanner; import java.io.PrintStream; import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author @zhendeaini6001 */ public class Main { public ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
1746cbe4cdaa92d43f91cc2f691968e9
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Stack; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author andrey */ public class CC { public static void main(String aewgd[])throws Exception{ BufferedRead...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
6eb14ac09f1604da9e4cac780e7e0836
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class MaximalSubsequence { /** * @param args */ public static void main(String[] args) { Scanner in = new Scanner(System.in); String input = in.next(); int[] maxCharIndex = new int[input.length()]; maxCharIndex[maxCharIndex.length - 1] = maxC...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
d30dfaf7b5e1686fd9126ca7b6ae0f8d
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.io.InputStream; public class C124 { public static void main(...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
ddc4b8d44746514d1ee4acd9ec24379e
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import static java.lang.Math.*; import java.util.*; import java.io.*; public class C { public void solve() throws Exception { char[] s = nextLine().toCharArray(); LinkedList<Integer>[] ll = new LinkedList[30]; for (int i=0; i<30; ++i) ll[i] = new LinkedList<Integer>(); for (int i=0; i<s.length; ++i) ll[s[...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
46b6d4ae75263203b96fa8ae44692e04
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.*; /** * */ public class Solution { /** * @param args */ public static void main(String[] args){ try { BufferedReader reader =new BufferedReader(new InputStreamReader(System.in)); // STDIN String str=reader.readLine().trim(); String subsequence=""; ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
66718ef612e67ca52ac6f32196fbe5e7
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.nextLine(); ArrayList<Integer> ar = new ArrayList<Integer>(); char max = 'a'; for ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
e5d12294f9ab8dcc8b3df828c5d5b364
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main(String args[]) throws IOException { Scanner c=new Scanner(System.in); String s=c.nextLine(); char A[]=(""+((char)('a'-1))+s).toCharArray(); int N=A.length; int maxLoc[]=new int[N]; maxLoc[N-1]=-1; if...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
ca2c39cf985137fdfa05231faedd3bad
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.Scanner; public class C { public String solve( String sample){ StringBuffer res = new StringBuffer(); char [] cs = sample.toCharArray(); char last = 0; int lastIdx = 0; char min = cs[0]; for( int i=0;i<cs.length;i++){ if( min > cs[i]) min = cs[i]; } while( true) { char now = 0...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
0581dff244f272e9303cad35cff668e4
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
//package contest_124_div2; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Reader; import java.io.StreamTokenizer; import java.io.Writer; import java.util.Arrays; import...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
14739eadd8198e1ec6ba46c32f841d03
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.*; import java.io.*; public class L { public static void main(String args[]) { Scanner sn=new Scanner(System.in); String str=sn.next(); int lo,hi,loc; lo=0; hi=-1; int ch=(int)'z'; while(ch>96) ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
ec941792230cf74681a1a885425da3e1
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputStream inputStream = System....
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
837d4ff00d95ad82861b1ed3c9835eee
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.*; public class SearchSubstring2{ public static void main(String[] args){ Scanner stdIn = new Scanner(System.in); String str = stdIn.next(); StringBuilder save = new StringBuilder(Character.toString(str.charAt(str.length()-1))); for(int i = str.length()-2; i >= 0; i--){ if( save.char...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
e9b581adfb87c403c0be194551e030c0
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class C { String line; StringTokenizer inputParser; BufferedReader is; FileInputStream fstream; DataInputStream in; String FInput=""; void openInput(String file) { if(file==null)is = new BufferedReader(new InputStreamReader(System...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
ce52f3d8952c0f6407e8ebc4470bd8d0
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.*; import java.util.ArrayList; public class Template { public static void main(String args[]) throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); char[] kar = in.readLine().toCharArray(); ArrayList<Character> res = new ArrayList<Chara...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
4ba64bc9facb8e4d0e297adafc878af1
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.Scanner; public class Main { public void run() { Scanner sc = new Scanner(System.in); String str = sc.next(); StringBuilder st=new StringBuilder(); char min='a'; for(int i=str.length()-1;i>=0;i--){ if(min<=str.charAt(i)){ min=s...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
034b15a53c0d2810490d9e5de35a82b3
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.*; import java.util.*; import java.math.*; /** * * @author Magzhan */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
cf056229f1dfee387003e2acc7c8815f
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; public class C { public static void main(String[] args) throws IOException{ BufferedReader bf = new BufferedReader(new...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
97e41d57138a36afa955ddfa7066d84b
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class TC { static ArrayList<Integer>[] loc; static String s; static void init() { loc = new ArrayList[ 26 ]; for( int i=0; i<s.length(...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
44d3049c42baa6ce173234ce16e01a79
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.*; /** * Created by IntelliJ IDEA. * User: piyushd * Date: 3/26/11 * Time: 10:53 PM * To change this template use File | Settings | File Templates. */ public class TaskC { void run() { String s = next(); ArrayList<Integer> [] pos = new ArrayList[26]; for (int i = 0; ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
6781147282d046be7bc8ffffad5dfeb1
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int l = s.length(); int[] c = new int[256]; for (int i = 0; i < l; i++) { c[s.charAt(i)]++; } ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
cb3d0e25048bdd93a146846d3692a862
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] Args) { char[] s = ss().toCharArray(); StringBuilder b=new StringBuilder(s[s.length-1]+""); for (int i = s.length-2; i >=0; i--) { if (s[i]>=b....
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
328961a98b1a0b4f99462f8ecb2c5611
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] Args) { char[] s = ss().toCharArray(); StringBuilder b=new StringBuilder(s[s.length-1]+""); for (int i = s.length-2; i >=0; i--) { if (s[i]>=b....
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
8a0f0d7932d72da1e05885580ed03552
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.*; public class C { public static void main(String[] args) throws Exception { new C().solve(); } void solve() throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = in.readLine(); int idx = 0; char ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
9531047546c720648450dd75eec823d8
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class C { static BufferedReader reader; static StringTokenizer tokenizer; static PrintWriter writer; static void init() { reader = new BufferedRea...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
19857271f0cc108af985965d3f1800fb
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.*; public class C { public static void main(String[] args) throws IOException { BufferedReader r; r = new BufferedReader(new InputStreamReader(System.in)); //r = new BufferedReader(new FileReader(new File("in.txt"))); char[] c = r.readLine().toCharArray(); int n = c.length; char[] s = new ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
f205194c36ea9671f97e33e4a05247c4
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Sergey Parkhomenko */ publi...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
a426ec8571a20e0ff8fe92493eb808c4
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StreamTokenizer; public class Main { public static void main(String[] args) throws Exception { char[] c = inB.readLine().toCharA...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
dd5716872eca40719b1bdf576a98a842
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
//package div124; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class C { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); StringBuilder ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
baacd29f80ef5babe06b23ca7b5f6ce0
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public void solve( ) throws Throwable { int last = -1; char ch[ ] = in.next( ).toCharArray( ); StringBuilder ans = new StringBuilder( ); for ( char c = 'z'; c >= 'a'; --c ) { //debug( c, last ); for ( ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
e5ab32208adc217ff9605ceb85a9b3c2
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class CFTest2 { static BufferedReader br; public static void main(String[]args){ br=new BufferedReader(new InputStreamReader(System.in)); try{ String ...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
5f32b7ae491717d358f3abaaf836d5c3
train_003.jsonl
1339506000
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 &lt; p2 &lt; ... &lt; pk ≤ |s|) a subsequence of string s = s1s2... s|s|.String x = x1x2... x|x| is lexicographically larger than string y ...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class C_124C { static class A implements Comparable<A>{ int x,i; public int compareTo(A o) { if(this.x<o.x || this.x==o.x && this.i>o.i) return 1; return 0; } } public static void main(String[] args) throws IO...
Java
["ababba", "abbcbccacbbcbaaba"]
2 seconds
["bbba", "cccccbba"]
NoteLet's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).The first sample: aBaBBAThe second sample: abbCbCCaCbbCBaaBA
Java 6
standard input
[ "implementation", "sortings", "greedy", "strings" ]
77e2a6ba510987ed514fed3bd547b5ab
The single line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 105.
1,100
Print the lexicographically maximum subsequence of string s.
standard output
PASSED
a1975df612e099d4cdd2d9c9bbd8eeec
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.io.*; import java.math.BigInteger; import java.util.*; public class C { String line; StringTokenizer inputParser; BufferedReader is; FileInputStream fstream; DataInputStream in; String FInput=""; void openInput(String file) { if(fi...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
d37ac5b23ccf268c4b16e5965078ad05
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.util.*; import java.io.*; public class man { public static void main(String args[]) throws IOException{ BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); String s[]=in.readLine().split(" "); int n=Integer.parseInt(s[0]); int m=Integer.parseInt(s[1]); int arr[...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
6f9513e201a12bf07c29299f4c7b1eb2
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
/* * Code Author: Jayesh Udhani * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar) * 2nd Year ICT BTECH Student */ import java.io.*; import java.util.*; public class hike { public static void main(String args[]) { InputReader in = new InputReader(System.in); Outpu...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
9f5197e50fa9bd9ba578963f6a3722b5
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
3e8a3a6f1a82b2ff19fbc79f4d20d098
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.util.Scanner; public class Tester { public static void main(String args[]){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextInt(); long total; long d; long h; long x = 0; long y = 0; long dl = 0; long hl = 0; int hight; int max = 0; int flag = 0; ...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
695fc1410d33102708f251b56a98e9a2
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.nio.ReadOnlyBufferException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashS...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
1e68deb711638909976f0e515cb40208
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.util.*; import java.io.*; public class CF_rnd300C { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; void solve() throws IOException { int n = nextInt(); int m = nextInt(); int[] d = new int[m]; int[] h = new int[m]; for(int i =...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
6dd614c7dffd936091c9e5d82511d60a
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
/** * Created by gosugdr on 4/26/15. */ import java.util.*; import java.io.*; public class C { FastScanner in; PrintWriter out; class Point { int d; int h; public Point(int d, int h) { this.d = d; this.h = h; } public Point() { }...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
f74966ff7178091aabd157a6a37ffd44
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class TouristNotes1 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub MyScanner input = new MyScanner(); int n = input....
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
fd2a1086f1c65e9ac9833ff670b97982
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; import java.io.InputStream; import java.io.InputStreamReader; /** * Built using CHelper plug-in * Actual solution is at the top * @author Artyom Korzun */ public cla...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
0c127a92565c65485e1f192bec694e05
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class cf { static int n; static int m; static Integer arr[]; public static void main(String[] args)throws IOException { PrintWriter out= new PrintWriter(System.out); Scanner sc=new Scanner(System.in); n=sc.nextI...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
87334f3e657f8ad43e23526a64fdb834
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws FileNotFoundException { InputReader in = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); i...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
6fd2182b4cb572f6a5bba96abf525dc9
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; public class C { public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String[] l = bf.readLine().split(" "); long n = Integer.parseInt(l[0]); ...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
945059e340e381630cf99d9fe855b71d
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.util.*; public class SolutionC { public static void main(String args[]){ Scanner s1=new Scanner(System.in); int n=s1.nextInt(); int r=s1.nextInt(); List<Integer> day=new ArrayList<Integer>(); List<Integer> height=new ArrayList<Integer>(); long max=-1; ...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
482205105e1be9742d1a298a398fe930
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.util.Scanner; public class C { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(), m = scn.nextInt(); int maxHeight = 0; int lastDay = scn.nextInt(), lastHeight = scn.nextInt(); int firstHeight = lastDay - 1 + lastHeight; maxHeight =...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
75e6bb902c382aeb78305b55551ad80b
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.util.InputMismatchException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution is at the to...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
187f2d2abe2427f5534099b74de30ae9
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.util.InputMismatchException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution is at the to...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
26b2008d19bfcb59eecd1c36f8a1bf9f
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.InputStream; import java.util.NoSuchElementException; import java.io.OutputStreamWriter; import java.math.BigInteger; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.IOException; /** *...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
afafc1c564af3b0f544ef52b42f56a12
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.util.*; import java.io.*; public class Class{ public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); ...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
2a28e60f2503e16192bdddc1812fcbe0
train_003.jsonl
1430064000
A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String ars[]) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); int m = sc.nextInt(); long max = 0; long[][] ar = new long[m][2]; for (int i = 0; i < m; i++) { ar[i][0] =...
Java
["8 2\n2 0\n7 0", "8 3\n2 0\n7 0\n8 3"]
2 seconds
["2", "IMPOSSIBLE"]
NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.
Java 8
standard input
[ "greedy", "math", "implementation", "binary search", "brute force" ]
77b5bed410d621fb56c2eaebccff5108
The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on...
1,600
If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).
standard output
PASSED
7cbcfb776a1b2305c33225bf20040785
train_003.jsonl
1365796800
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentively and use it as a formal document.In the Pindows operating system a strings ar...
256 megabytes
/** * @author egaeus * @mail sebegaeusprogram@gmail.com * @veredict Not sended * @url <https://codeforces.com/problemset/problem/291/B> * @category ? * @date 9/06/2020 **/ import java.io.*; import java.util.*; import static java.lang.Integer.*; import static java.lang.Math.*; public class CF291B { public...
Java
["\"RUn.exe O\" \"\" \" 2ne, \" two! . \" \"", "firstarg second \"\""]
1 second
["&lt;RUn.exe O&gt;\n&lt;&gt;\n&lt; 2ne, &gt;\n&lt;two!&gt;\n&lt;.&gt;\n&lt; &gt;", "&lt;firstarg&gt;\n&lt;second&gt;\n&lt;&gt;"]
null
Java 11
standard input
[ "implementation", "*special", "strings" ]
6c7858731c57e1b24c7a299a8eeab373
The single line contains a non-empty string s. String s consists of at most 105 characters. Each character is either an uppercase or a lowercase English letter, or a digit, or one of the ".,?!"" signs, or a space. It is guaranteed that the given string is some correct command line string of the OS Pindows. It is guaran...
1,300
In the first line print the first lexeme, in the second line print the second one and so on. To make the output clearer, print the "&lt;" (less) character to the left of your lexemes and the "&gt;" (more) character to the right. Print the lexemes in the order in which they occur in the command. Please, follow the given...
standard output
PASSED
65f6346e92fae23bb11370d8b4f1c7c8
train_003.jsonl
1365796800
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentively and use it as a formal document.In the Pindows operating system a strings ar...
256 megabytes
import java.util.*; import java.io.*; public class vv{ public static void main(String[] args) throws IOException{ // Scanner no=new Scanner(System.in); BufferedReader no=new BufferedReader(new InputStreamReader(System.in)); String s=no.readLine(); s.replaceAll("\\s"," "); int i; for(i=0;i<s.length();i++){ ...
Java
["\"RUn.exe O\" \"\" \" 2ne, \" two! . \" \"", "firstarg second \"\""]
1 second
["&lt;RUn.exe O&gt;\n&lt;&gt;\n&lt; 2ne, &gt;\n&lt;two!&gt;\n&lt;.&gt;\n&lt; &gt;", "&lt;firstarg&gt;\n&lt;second&gt;\n&lt;&gt;"]
null
Java 11
standard input
[ "implementation", "*special", "strings" ]
6c7858731c57e1b24c7a299a8eeab373
The single line contains a non-empty string s. String s consists of at most 105 characters. Each character is either an uppercase or a lowercase English letter, or a digit, or one of the ".,?!"" signs, or a space. It is guaranteed that the given string is some correct command line string of the OS Pindows. It is guaran...
1,300
In the first line print the first lexeme, in the second line print the second one and so on. To make the output clearer, print the "&lt;" (less) character to the left of your lexemes and the "&gt;" (more) character to the right. Print the lexemes in the order in which they occur in the command. Please, follow the given...
standard output
PASSED
17b7d9de6da3e5be72dbfe87c4f44061
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class Main extends Reader { public static void main(String[] args) throws IOException { int n = ni(), a = ni(), b = ni(), k = ni(), p = 0, sum = 0; String s = ns()+"1"; int len[] = new int[n]; int pos[] = new int[...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
8aef521732c566fbfa7b6171a4f0bbc9
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
// practice with rainboy import java.io.*; import java.util.*; public class CF737B extends PrintWriter { CF737B() { super(System.out); } static class Scanner { Scanner(InputStream in) { this.in = in; } InputStream in; int k, l; byte[] bb = new byte[1 << 15]; byte getc() { if (k >= l) { k = 0; try { ...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
98d257d6c2d60c47ebb6b54515d22d9e
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.StringTokenizer; public class B2 { public static void main(String[] args) { FastScanner $ = new Fa...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
a3c38f186cb7f3ca183894f883872653
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; import java.io.*; import java.util.*; public class ProblemB { public static void main(String[] args) { // TODO Auto-generated method stub FastScanner input = new FastScanner(); int length = input.nextInt(); int numShips = input.nextInt(); int lengthOfSh...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
8776e525efb8ded0aa3ecc6f71635ab1
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
import java.io.*; import java.util.*; import java.util.List; public class Template implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() throws FileNotFoundException { try { in = new BufferedReader(new FileReader("inpu...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
5ecf715c7a2b5832102d8513cc8e6e0d
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; impo...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
f229f7e5ed404a73ccf760591619cf2c
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class b { public static void main(String[] args) throws IOException { FastScanner in = new FastSc...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
e31d5c5bf1bdf20311d543c9f687c883
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
import java.io.*; import java.util.*; import java.util.concurrent.PriorityBlockingQueue; public class B { InputStream is; int __t__ = 1; int __f__ = 0; int __FILE_DEBUG_FLAG__ = __f__; String __DEBUG_FILE_NAME__ = "src/T"; FastScanner in; PrintWriter out; class State implements Comparable<State> { int le...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
91a860569e3c0f0dc1bce6eb3db452a5
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.InputMismatchException; public class B { public static void main(String[] args) { FastScannerB sc = new FastScannerB(System.in); int N = sc.nextInt(); int A = sc.nextInt(); int B = sc.nextInt(); int K = ...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
850def7e68f45d22b24972cb96dbc5db
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
//package com.company; import java.io.*; import java.util.*; public class Main { static long TIME_START, TIME_END; public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); // Scanner sc = new Scanner(new FileInputStream("Test.in")); PrintWriter pw...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
7959c66a738da9c3a80cef568d73694f
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
// package codeforces.other2017.technocup2017.round2.div1; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.util.concurrent.ArrayBlockingQueue; public class B { public static void main(String[] args) { InputReader in = new InputReader(Syst...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
a2c42c2294d3d6c6874ff587ba3f08dc
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
//package tech2016.elim2; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class B { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(),...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
f573846890f33a37c0832a066aace7ee
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
import java.awt.*; import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.List; import static java.lang.Math.max; import static java.lang.Math.min; public class B implements Runnable{ // SOLUTION!!! // HACK ME PLEASE IF YOU CAN!!! // PLEASE!!! ...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
3339ae34619f961d04452e8ebecb34b1
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class B { public void run() throws FileNotFoundException { //Scanner sc = new Scanner(new File("B.txt")); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a = sc.nextInt(); ...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
a390f14539f7b5f193fb48ee5bb5a327
train_003.jsonl
1479632700
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot sh...
256 megabytes
import java.io.*; import java.util.*; public class B implements Runnable { private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; private BufferedReader in; private PrintWriter out; private StringTokenizer tok = new StringTokenizer(""); private void init() throws...
Java
["5 1 2 1\n00100", "13 3 2 3\n1000000010001"]
1 second
["2\n4 2", "2\n7 11"]
NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy", "math" ]
d50bb59298e109b4ac5f808d24fef5a1
The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-...
1,700
In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from ...
standard output
PASSED
46dea28d691f489eec379af25c241c19
train_003.jsonl
1346427000
The Little Elephant loves playing with arrays. He has array a, consisting of n positive integers, indexed from 1 to n. Let's denote the number with index i as ai. Additionally the Little Elephant has m queries to the array, each query is characterised by a pair of integers lj and rj (1 ≤ lj ≤ rj ≤ n). For each query lj...
256 megabytes
// practice with kaiboy import java.io.*; import java.util.*; public class CF221D extends PrintWriter { CF221D() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF221D o = new CF221D(); o.main(); o.flush(); } int[] ft; void update(int i, int n, int a) { whil...
Java
["7 2\n3 1 2 2 3 3 7\n1 7\n3 4"]
4 seconds
["3\n1"]
null
Java 11
standard input
[ "data structures" ]
5c92ede00232d6a22385be29ecd06ddd
The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 105) — the size of array a and the number of queries to it. The next line contains n space-separated positive integers a1, a2, ..., an (1 ≤ ai ≤ 109). Next m lines contain descriptions of queries, one per line. The j-th of these lines contains the...
1,800
In m lines print m integers — the answers to the queries. The j-th line should contain the answer to the j-th query.
standard output
PASSED
152dec5781c5d71229681bf64780f792
train_003.jsonl
1423931400
Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in a certain way. Initially the memory of the mechanism is filled with n strings. Then the mechanism should be able to process queries of the following type: "Given string s, determine if the memory of the mech...
256 megabytes
import java.util.Scanner; public class Main { public static class Node { private Node[] children = new Node[3]; private boolean isWord; public Node() { isWord = false; for (int i = 0; i < 3; i++) children[i] = null; } void add(Strin...
Java
["2 3\naaaaa\nacacaca\naabaa\nccacacc\ncaaac"]
3 seconds
["YES\nNO\nNO"]
null
Java 8
standard input
[ "hashing", "string suffix structures", "data structures", "binary search", "strings" ]
146c856f8de005fe280e87f67833c063
The first line contains two non-negative numbers n and m (0 ≤ n ≤ 3·105, 0 ≤ m ≤ 3·105) — the number of the initial strings and the number of queries, respectively. Next follow n non-empty strings that are uploaded to the memory of the mechanism. Next follow m non-empty strings that are the queries to the mechanism. Th...
2,000
For each query print on a single line "YES" (without the quotes), if the memory of the mechanism contains the required string, otherwise print "NO" (without the quotes).
standard output
PASSED
e9dedbcd35ce58a8d99125ae69b71922
train_003.jsonl
1423931400
Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in a certain way. Initially the memory of the mechanism is filled with n strings. Then the mechanism should be able to process queries of the following type: "Given string s, determine if the memory of the mech...
256 megabytes
import java.util.*; import java.io.*; public class WattoMechanism { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); String[] in = br.readLine().split(" "); int n = Integer.pars...
Java
["2 3\naaaaa\nacacaca\naabaa\nccacacc\ncaaac"]
3 seconds
["YES\nNO\nNO"]
null
Java 8
standard input
[ "hashing", "string suffix structures", "data structures", "binary search", "strings" ]
146c856f8de005fe280e87f67833c063
The first line contains two non-negative numbers n and m (0 ≤ n ≤ 3·105, 0 ≤ m ≤ 3·105) — the number of the initial strings and the number of queries, respectively. Next follow n non-empty strings that are uploaded to the memory of the mechanism. Next follow m non-empty strings that are the queries to the mechanism. Th...
2,000
For each query print on a single line "YES" (without the quotes), if the memory of the mechanism contains the required string, otherwise print "NO" (without the quotes).
standard output