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
1b8ab2a2ae8e192f327f8f6283cd985a
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class code2 { InputStream is; PrintWriter out; ArrayList<Integer> al[]; long mod=(int)Math.pow(10,9)+7; void solve() { int n=ni(); int a[]=na(n); int max=100000; long freq[]=new long[max+1]; for(int i=0;i<n;i++) freq[a[i]]++; long ans...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
c6858971b7c5f48f86abc29601499671
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
//package ECR20; import java.util.*; public class F803 { static final int MODULO = (int)1e9 + 7; static final int MAX = (int)1e5 + 5; static int n; static int f[] = new int[MAX]; static int mu[] = new int[MAX]; /** * * @param a 0 <= a < MODULO * @param b 0 <= b < MODULO ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
da1ec22c5a824fec0675d228173794cb
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.*; import java.util.*; public class Main implements Runnable { FastReader scn; PrintWriter out; String INPUT = ""; void solve() { int n = scn.nextInt(), max = 100000 + 1, mod = 1000_000_007; int[] arr = new int[max]; for (int i = 0; i < n; i++) { arr[scn.nextInt()]++; } int[] count = ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
e764149f4889cf856dea6e4b16455f8a
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
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.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solutio...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
97f9ad74329127789b5854ce0045fb4f
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; public class MainS { static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L; static final int INf = 1_000_000_000; static FastReader reader; static PrintWriter writer; public static void main(String[] args) { ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
25c4117a2aa0d7e5f664b2e6501203fb
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper p...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
e295bd53b631a38337054981cf942933
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = 100000; int p = 1000000007; int c[] = new int[m + 1]; int s[] = new int[m + 1]; int b[] = new int[m + 1]; for (int i = 0; i < n; i++) { c[in.next...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
5034ddd165697f51ac39bed5e87675dd
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.*; import java.io.*; public class EdB { static ArrayList<Integer> primes; public static void main(String[] args) throws Exception{ long num = 1000000007; // TODO Auto-generated method stub BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new Print...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
e125da02272570cb04d37c9fc40f4078
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public c...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
006348744eabad86d58af0d003085566
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public c...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
2f909afad951c17d2c1cfebfbe5eee40
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; FastReader() { br = new BufferedReader(new ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
6651bbb0aee2b420e1c205578581ac4a
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
/*Author: Satyajeet Singh, Delhi Technological University*/ import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.*; public class Main{ /*********************************************Constants******************************************/ static PrintWriter ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
32419c6cd81128a5afbc53bf44adbe46
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; public class Main{ //SOLUTION BEGIN //Into the Hardware Mode void pre() throws Exception{} void solve(int TC) throws Exception{ int n = ni(), mx = 100000; int[] f = new int[1+mx]; for(int i = 0; i< n; i++)f[ni()]++; ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
4b73b025b62f8b7c92b7104506917184
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; public class Main{ //SOLUTION BEGIN //Into the Hardware Mode void pre() throws Exception{} void solve(int TC) throws Exception{ int n = ni(), mx = 100000; int[] f = new int[mx+1]; for(int i = 0; i< n; i++)f[ni()]++; ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
35681d56388709de33fd8e3b245b8e96
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author beginner1010 */ public cla...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
5a40f70541b1fc93dc916d57ef80b54b
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
85e26ac4dc596a462e0b30c43e17438f
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
ca24394f7e29658eaa40e55500cc4190
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
//package educational.round20; 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 F { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
38bb0db94fb0446dfe46797d62db6269
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class q5 { static long modPow(long x, long pow,long mod) { long res=1; x%=mod; while(pow>0) { if((pow&1)!=0) res*=x; pow>>=1; x*=x; x%=mod; res%=mod; } return res; } public stati...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
ea91eea82abde749d209012c4f52940d
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class h { public static void main(String[] args) throws Exception { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(f.readLine()); int[] a = new int[n], cnt = new int...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
3dc5603433e565e9c5a5f799762540b5
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
adca2b7c2320223c563638f0c48ac1ed
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
/** * @author prakhar28 * */ import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class Main{ static class Reader { final private int BUFFER_SIZE = 1 << 16; ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
1f4480ff3605d2b202e18f6e849b4fcd
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** What do you think? What do you think? 1st on Billboard, what do you think of it Next is a Grammy, what do you think of it However you think, I’m sorry, but shit, I have no fcking inter...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
d5050c4bf62a6013e4d604da684619ff
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
/* 合 */ import java.io.*; import java.util.*; import java.math.*; public final class co_prime_subs { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); static Random rnd=new Random(...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
e4c836a9b175f60277a9ffc269bbdc23
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * @author khokharnikunj8 */ public class Main { public static void main(String[] args) { ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
d095b1ca035d3ccd718d422565799fc9
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.*; import java.io.*; public class CFA { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; private static final long MOD = 1000L * 1000L * 1000L + 7; private static final int[] dx = {0, -1, 0, 1}; private static final int[] dy = {1, 0, -1, 0}; private static final Str...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
178a67bdef183eb8ff8759b26fad7740
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Edu_20F { static long MOD = 1_000_000_007; public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(Syste...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
bc84541d798e580568961dcc4cd76924
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class A implements Runnable { private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; private BufferedReader in; private PrintWriter out; private StringTokenizer tok = new StringTokenizer(""); ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
394e9b558cbe24dd6edcd324c1e1b0e9
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) {new Main().run();} FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ work(); out.flush(); } long mod=1000000007L; long inf=Long.MAX_VALUE; long gcd(long a,long b) { ...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
fcc7452c94de8a460d9fa39faf8de566
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.*; import java.math.*; import java.io.*; import java.text.*; public class A{ //public static PrintWriter pw; public static PrintWriter pw=new PrintWriter(System.out); public static void solve() throws IOException{ // pw=new PrintWriter(new FileWriter("C:\\Users\\shree\\Downloads\\small_output_in"));...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
031cf80774331c00a739cd0dcfd68388
train_003.jsonl
1493391900
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1.Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.Note that t...
256 megabytes
import java.util.*; import java.io.*; public class Main{ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); static int[] dp = new int[100001], Mult = new int[1000...
Java
["3\n1 2 3", "4\n1 1 1 1", "7\n1 3 5 15 3 105 35"]
2 seconds
["5", "15", "100"]
NoteIn the first example coprime subsequences are: 1 1, 2 1, 3 1, 2, 3 2, 3 In the second example all subsequences are coprime.
Java 8
standard input
[ "combinatorics", "number theory", "bitmasks" ]
2e6eafc13ff8dc91e6803deeaf2ecea5
The first line contains one integer number n (1 ≀ n ≀ 100000). The second line contains n integer numbers a1, a2... an (1 ≀ ai ≀ 100000).
2,000
Print the number of coprime subsequences of a modulo 109 + 7.
standard output
PASSED
032e089b01118c2f68475787f26942c3
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; import java.math.*; public class Main{ public static StringTokenizer token = new StringTokenizer(""); public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static PrintWriter output = new PrintWriter(System.out); publ...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
78cdc08e0f0e05c979c7f47b41819614
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.lang.reflect.Array; import java.util.*; import javafx.util.Pair; public class Codeforces { public static void main(String[] args) { Scanner s = new Scanner(System.in); String str = s.next(); int[] sum = new int[str.length()]; for (int i = 0; i < str.length()-1; i++) ...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
9baf51952c4e1ff22876af5d31647f26
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; public class IlyaAndQueries { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); Stri...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
fb0fef7863d3567fb7e63c9831d8de12
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; public class IlyaAndQueries { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); Stri...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
9c0e2777a784f97c4276f4de7a600f9d
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import javafx.util.Pair; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); String str = cin.nextLine(); int ...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
793d3620cc503aac2138c2c10e57831f
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
/** * Created by daeun on 2017-04-28. */ import java.util.Scanner; public class algo313B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String str = scan.nextLine(); int len = str.length(); int[] check = new int[len]; check[0]=0; ...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
4de3749ff41403482e2cd6a1bf2525f3
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.io.*; public class Main2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); int len = str.length()-1, n = Integer.parseInt(br.readLine()); int[] matches = new int[len], range = new in...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
9c3b370b953fbad9500189752313056c
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.io.*; public class Main2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); int len = str.length(), n = Integer.parseInt(br.readLine()); int[] range = new int[len]; range[0] = 0; ...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
002e9b6835e4b966dddc8851761ab9d4
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
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)); String str = br.readLine(); int len = str.length(); int[] matches = new int[len+1]; matches[0] = 0; for(int i = ...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
a51554356d99a4f4c4c5913b7d7e7552
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; public class Queries{ public static void main(String[] args) throws Exception{ FastScanner reader = new FastScanner(System.in); StringBuilder out = new StringBuilder(); char[] in = reader.next().t...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
4fc3dc6d65a29e21d0b3248cc9708685
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; public class Queries{ public static void main(String[] args) throws Exception{ FastScanner reader = new FastScanner(System.in); StringBuilder out = new StringBuilder(); char[] in = reader.next().t...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
08ef96d9df3ab6c0f99f2be92ad62107
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.util.*; import java.io.*; public class IlyaAndQueries { public static void main(String[] args) { Scanner in = new Scanner(System.in); int x,y,n; String s; s=in.next(); char[] arr = s.toCharArray(); n=in.nextInt(); int length=s.length(); int an...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
ddb712c2a607f2c315d38a79c2e6829d
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.io.*; public class CF313B { static int m, prefix[] = new int[100001], l, r; static String in, ins[]; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new O...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
953fad5db0fadea3d81b51499c735e56
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String s = scanner.nextLine(); int queries = scanner.nextInt(); scanner.nextLine(); int[] m...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
e384fe8da596cfd75a9a129f6f36e8da
train_003.jsonl
1369927800
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≀ li &lt; ri ≀ n...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class su0{ public static void main(String[]args) { Scanner sc=new Scanner(System.in); String line=sc.next(); sc.nextLine(); int j=0; int arr[]=new int [line.length()+1]; int i; bo...
Java
["......\n4\n3 4\n2 3\n1 6\n2 6", "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4"]
2 seconds
["1\n1\n5\n4", "1\n1\n2\n2\n0"]
null
Java 8
standard input
[ "dp", "implementation" ]
b30e09449309b999473e4be6643d68cd
The first line contains string s of length n (2 ≀ n ≀ 105). It is guaranteed that the given string only consists of characters "." and "#". The next line contains integer m (1 ≀ m ≀ 105) β€” the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integer...
1,100
Print m integers β€” the answers to the queries in the order in which they are given in the input.
standard output
PASSED
ebee09817c8117e5a17c025cf77a489d
train_003.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≀ i ≀ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author pandusonu */ public class ...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 8
standard input
[ "math" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len β€” the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
9d186e0a3813ca871fa00846c61b0b29
train_003.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≀ i ≀ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
import java.util.Scanner; public class HammingDistance194E { private static String[] combination = { "aaaaaaa", "aaabbbb", "abbaabb", "bababab" }; public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] h = new int[6]; for (int i = 0; i < 6; i++) h[i] = in.nextInt(); int[] ...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 6
standard input
[ "math" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len β€” the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
87a037499ef3ec4a3d91cff185613c51
train_003.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≀ i ≀ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Test { static BufferedReader reader; static StringTokenizer tokenizer; static PrintWriter writer; static int nextInt() throws IOException { retu...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 6
standard input
[ "math" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len β€” the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
8e71ad27cd32ed6aa9a76652e10dc8ce
train_003.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≀ i ≀ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
import java.util.Scanner; public class HammingDistance194E { private static String[] combination = { "aaaaaaa", "aaabbbb", "abbaabb", "bababab" }; public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] h = new int[6]; for (int i = 0; i < 6; i++)...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 6
standard input
[ "math" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len β€” the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
4e3f2f84987aa077d5c60d91874bed16
train_003.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≀ i ≀ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; public class Main { public static void main(String[] args) throws IOException { (new Main()).solve(); } public void Main() { } void solve() throws IOException { // BufferedReader in = new BufferedReader(new // I...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 6
standard input
[ "math" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len β€” the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
9470b6397d1dd7d12a5ab7146698ea08
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new Pr...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
88c5762b6ce85c2bb2086d1b6ecccc4a
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.util.*; import java.io.*; public class Div2B { public static void main(String[] args) throws IOException { new Div2B().run(); } FastScanner in; PrintWriter out; void run() throws IOException { in = new FastScanner(System.in); out = new PrintWriter(System.out, false); solve(); out.close();...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
1204226a584af7a1e8d26d5953a1d233
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
//package com.morazow.cf; import java.io.*; import java.util.*; public class CF222B { public static void main(String[] args) { ArrayBufferScanner scanner = new ArrayBufferScanner(System.in); PrintWriter output = new PrintWriter(new OutputStreamWriter(System.out)); int N = scanner.nextInt...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
62855b7723ef82cf8fa0f027fee5a3ce
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class CosmicTables { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWrit...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
8771bcfba2ff8d72ed28b4dcc38cc54f
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class q4 { public static void main(String[]args) throws IOException { Sc...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
06a0c6d6146f7ecbf42e7ea60d566279
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
// δ½œθ€…οΌšζ¨ζˆη‘žε…ˆη”Ÿ import java.io.*; import java.util.*; public class cf222b { static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokeniz...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
5d293799953ecd27d58c0efa4a69c741
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
//package forces; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.List; public class P_222B { public static void main(String[] args) throws IOException { ...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
a06f31d7039e31bfdc0a8d62b666cb1c
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.IOException; import java.util.StringTokenizer; import java.io.InputStreamReader; import java.io.BufferedReader; import java.math.BigDecimal; import java.math.BigInteger; import java.math.MathContext; import java.util.ArrayList; import java.util.Collections; import java.util.TreeSet; import java.util.*; ...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
0f63fdc7994f062125ce7b19ce99d84b
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main{ public static void main(String[] args) throws Exception{ BufferedReader f=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out=new PrintWriter(System.out); Scanner s=new Scanner(System.in); String split[]=f.r...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
d6e38f73f4edab00ca77f79d23ae5dc8
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** *...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
9f10f4d6a05728a8f4c1da78529e7e3a
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.*; import java.util.*; public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { boolean env=System.getProperty("ONLINE_JUDGE") != null; if(!env) { try { br=new BufferedReader(new FileReader("...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
56c832e1af953c7347e0162f05ce1645
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.File; import java.io.FileNotFoundExcep...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
f98fa4cfec1e3fdd752553341e72e47b
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.util.Scanner; public class Main { FastScanner in; PrintWriter out; static class FastScanner { BufferedReader br; StringTokenizer st; FastScanner(InputStream in) { br = new BufferedReader(new In...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
eda9a438878887ba3eb1156e19e41ca5
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.util.*; import java.io.*; public class cf222b { public static void main(String[] args) throws Exception { // Scanner in = new Scanner(System.in); FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); ...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
8b4b433df87e75bc906c4e81de81c14e
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class CosmicTables { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; static void ...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
7a9413a09ae2d64679e22a3c83d7fe9a
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter w = new PrintWriter(System.out); String[] ss = br.readLine().trim().split("\\s+"); int t,i,n= In...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
0f3095ea0f6d9aac3e5a82f228019f17
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.*; import java.util.*; public class GFG { public static void main (String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); String str[] = br.readLine().spli...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
2450d500a728302af1afedc9feab1f83
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Jenish */ public class Ma...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
013c4fb61747acaf6060d49e08f60953
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.HashMap; public class Main { public static void main(String[] args) throws IOException { InputReader in ...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
3b8a75fbf654a97acac691e0173fccc7
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class CosmicTables implements Closeable { private InputReader in = new InputReader(System.in); ...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
79b898b21eadb3375947d77440442696
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; public class Main { public static void main(String[] args) { InputStream inputStream = System....
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
304ce0d03385d4a3fad3e918c8a5a227
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
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; import java.util.Scanner; /** * Built using CHelp...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
c478c70a623af88c953659c3bd7bb2b9
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
c6e7cd0c3fa433d653272bad101e8194
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args)throws IOException { FastReader f=new FastReader(); StringBuffer sb = new StringBuffer(); int n=f.nextInt(); int m=f.nextInt(); int k=f.nextInt(); int mat[][]=new int[n][m]; for(int i=0;i<n;i++) ...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
421815dbf5bc8b574c65085407d399b0
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class ct { public static void main(String[] args) { InputStream inputStream = System.in; InputReader sc = new InputReader(inputStream); int n=sc.nextInt(); int m=sc.nextInt(); int ...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
8276396e650041081c0f614ed25a146c
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; public class CosmicTables { public static void main(String args[]) throws IOException { Reader scan = new Reader(); StringBuilder sb = new StringBuilder(); int n = scan.nextInt(); int m = sc...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
546f00bd0e4d5616a517a97535203380
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
//package codeforces; import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java....
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
50c2b610d979699c1bc6a261c18af721
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class B222 { static int[][] data; static int[] row; static int[] col; public static void main(String[] args)throws Exception{ FastReader scan = new F...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
100923bbac983c0eee3c6aeac3200c27
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Throwable { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // BufferedReader br = new Buffered...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
fc75d476802e434eae22155c8ee549d4
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Solv...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
488bf8381f4ee76c7becd2391f1134c8
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.awt.Point; import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.String.*; import javafx.scene.paint.Color; public class...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
34fd7d9604cd764e9d7293da329d9b9e
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
b6f09955937b63f90263fbc44ede3387
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { FScanner in = new FScanner(System.in); int ...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
46ed7c45645c760cc8ccdf4cc759dfa8
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader br...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
70a0b47b8e152726a36e3c1484799009
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; import java.util.Arrays; public class Main { public static void main( String [] args ) throws IOException{ Scanner scan = new Scanner(System.in); in.init( System.in ); PrintWriter pw = new PrintWriter(System.out); int matrixRo...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
e9df2b2ff31c367dea91ba5a0b371a96
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); Scanner s = new Scanner(System.in); String[] spli...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
b7ed44ff0cd39c6a9cc4256e63806f8f
train_003.jsonl
1347291900
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. UCDHP stores some secret information about meteors as an n × m table with integers in its cells. The order of meteors in t...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import static java.lang.Integer.parseInt; import java.util.StringTokenizer; public class B_Cosmic_Tables { public static void main(String[] args) throws I...
Java
["3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2", "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3"]
3 seconds
["8\n9\n6", "5"]
NoteLet's see how the table changes in the second test case.After the first operation is fulfilled, the table looks like that:2 1 41 3 5After the second operation is fulfilled, the table looks like that:1 3 52 1 4So the answer to the third query (the number located in the first row and in the third column) will be 5.
Java 8
standard input
[ "data structures", "implementation" ]
290d9779a6be44ce6a2e62989aee0dbd
The first line contains three space-separated integers n, m and k (1 ≀ n, m ≀ 1000, 1 ≀ k ≀ 500000) β€” the number of table columns and rows and the number of queries, correspondingly. Next n lines contain m space-separated numbers each β€” the initial state of the table. Each number p in the table is an integer and satisf...
1,300
For each query to obtain a number (si = "g") print the required number. Print the answers to the queries in the order of the queries in the input.
standard output
PASSED
a78f3f13b2301cfcb2a979d5165ece21
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); T...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
b9e5a7000f8dae548ccc2dc81d4f43d7
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); T...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
62a3d2869e8ea3901e8aa495c9ee380e
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class Queue1 { static int mod = 1000000007; static InputReader in = new InputReader(System.in); static...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
3b7cb60cbd7043f5b6bc5b84f0ab1035
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
7be321f97944a2152474fde5d77b7edf
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.PrintWriter; public class D353 { static class Scanner { BufferedReader br; StringTokenizer tk=new StringTokenizer(""); ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
3ec645d832f7e1b81fb80ece3eb878b9
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.util.*; /* * Heart beats fast * Colors and promises * How to be brave * How can I love when I am afraid to fall... */ //read the question correctly (is y a vowel? what are the exact constraints?) //look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) public class Main...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
0135bdd85d2affa49943b26756ec5f42
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.util.*; import java.io.*; public class Queue { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE];...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
0dc1b76e9d1ddab463c614ca4435a57b
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
/* * Author- Priyam Vora * BTech 2nd Year DAIICT */ import java.io.*; import java.math.*; import java.util.*; import javax.print.attribute.SetOfIntegerSyntax; public cla...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
3b1ffe30db56484ffb7d1f8531132558
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public final class Queue205D { public static void main(String ar[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); char[] cc = br.readLine().toCharArray(); int cnt = 0, d...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
a8e84066f4a7b8a544a8ab892e7f6cc7
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.String.*; public class Main { public static void main(String[] args) throw...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
480c2213d87f9edc87ac6c84efb8ec52
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output
PASSED
8b90d239b31911870d2d46fe410e27ea
train_003.jsonl
1381419000
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning o...
256 megabytes
import java.io.*; public class CF353D { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); char[] cc = br.readLine().toCharArray(); int cnt = 0, delay = 0, max = 0; for (int i = 0; i < cc.length; i++) if (cc[i] == 'M') { ...
Java
["MFM", "MMFF", "FFMMM"]
1 second
["1", "3", "0"]
NoteIn the first test case the sequence of changes looks as follows: MFM  →  FMM.The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.
Java 8
standard input
[ "dp", "constructive algorithms" ]
8423f334ef789ba1238d34f70e7cbbc8
The first line contains a sequence of letters without spaces s1s2... sn (1 ≀ n ≀ 106), consisting of capital English letters M and F. If letter si equals M, that means that initially, the line had a boy on the i-th position. If letter si equals F, then initially the line had a girl on the i-th position.
2,000
Print a single integer β€” the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.
standard output