[go: up one dir, main page]

0% found this document useful (0 votes)
176 views2 pages

Prefix Min and Suffix Max Problem

The document describes a programming problem from Codeforces Round 1034 (Div. 3) involving an array of distinct integers. The task is to determine if a sequence of operations can transform the array into a single element array for each element. The output should be a binary string indicating the possibility for each element in the array across multiple test cases.

Uploaded by

Yhlas Yklymow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views2 pages

Prefix Min and Suffix Max Problem

The document describes a programming problem from Codeforces Round 1034 (Div. 3) involving an array of distinct integers. The task is to determine if a sequence of operations can transform the array into a single element array for each element. The output should be a binary string indicating the possibility for each element in the array across multiple test cases.

Uploaded by

Yhlas Yklymow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

9/2/25, 10:27 AM Problem - 2123C - Codeforces

|
stdfloat | Logout

HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN

PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST

Codeforces Round 1034 (Div. 3)


C. Prefix Min and Suffix Max Finished
time limit per test: 2 seconds Practice
memory limit per test: 256 megabytes

You are given an array a of distinct integers.

In one operation, you may either: → Virtual participation 


choose a nonempty prefix∗ of a and replace it with its minimum value, or Virtual contest is a way to take part in past contest,
as close as possible to participation on time. It is
choose a nonempty suffix of a and replace it with its maximum value.

supported only ICPC mode for virtual contests. If
you've seen these problems, a virtual contest is not
for you - solve these problems in the archive. If you
Note that you may choose the entire array a. just want to solve some problem from a contest, a
virtual contest is not for you - solve this problem in
the archive. Never use someone else's code, read
For each element ai , determine if there exists some sequence of operations to transform a into [ai ] ; that is, make the tutorials or communicate with other person
the array a consist of only one element, which is ai . Output your answer as a binary string of length n , where the i - during a virtual contest.

th character is 1 if there exists a sequence to transform a into [ai ] , and 0 otherwise. Start virtual contest

A prefix of an array is a subarray consisting of the first k elements of the array, for some integer k .

A suffix of an array is a subarray consisting of the last k elements of the array, for some integer k .
→ Clone Contest to Mashup 
Input
4
The first line contains an integer t (1 ≤ t ≤ 10 ) — the number of test cases.
→ Submit?
5
The first line of each test case contains one integer n (2 ≤ n ≤ 2 ⋅ 10 ) — the size of the array a.
6 Language: GNU G++20 13.2 (64 bit, winlibs)
The second line of each test case contains n integers, a1 , a2 , … , an (1 ≤ ai ≤ 10 ). It is guaranteed that all ai
are distinct. Choose
Choose File No file chosen
file:
5
It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10 .
Submit

Output
For each test case, output a binary string of length n — the i -th character should be 1 if there exists a sequence of
operations as described above, and 0 otherwise. → Contest materials

Example Announcement (en)


input Copy Tutorial (en)
3
6
1 3 5 4 7 2 → CF GetRating
4
13 10 12 20
*1000
7
1 2 3 4 5 6 7
Show All Tags
output Copy
Contest Standings
100011
1101
1000001

Note
In the first sample, you can first choose the prefix of size 3 . Then the array is transformed into

1 4 7 2

Next, you can choose the suffix of size 2 . Then the array is transformed into

1 4 7

Finally, you can choose the prefix of size 3 . Then the array is transformed into

So we see that it is possible to transform a into [1].

It can be shown that it is impossible to transform a into [3].

Codeforces (c) Copyright 2010-2025 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: Sep/02/2025 [Link]UTC+5 (h1).
Desktop version, switch to mobile version.
Privacy Policy | Terms and Conditions
[Link] 1/2
9/2/25, 10:27 AM Problem - 2123C - Codeforces
Supported by

[Link] 2/2

You might also like