0% found this document useful (0 votes)
22 views9 pages

Problems - Codeforces

The document outlines various programming contest problems, including tasks related to string manipulation, array analysis, and tree structures. Each problem specifies input and output requirements, along with examples to illustrate the expected results. The content is structured to guide participants in understanding and solving competitive programming challenges.

Uploaded by

omarandrock
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)
22 views9 pages

Problems - Codeforces

The document outlines various programming contest problems, including tasks related to string manipulation, array analysis, and tree structures. Each problem specifies input and output requirements, along with examples to illustrate the expected results. The content is structured to guide participants in understanding and solving competitive programming challenges.

Uploaded by

omarandrock
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
You are on page 1/ 9

Team Formation 2025

A. ACPC The fina


some s
1 second, 1024 megabytes marks o
student
Both Arab Collegiate Programming Contest and Aleppo Collegiate
provide
Programming Contest can be abbreviated with ACPC which could lead to
him. Th
ambiguity, but when you are in Aleppo Collegiate Programming Contest
given
then ACPC should mean Aleppo Collegiate Programming Contest, one of
your friends doesn't know that so you have to tell him what is the correct Input
meaning of ACPC, with knowing that you are at Aleppo Collegiate The firs
Programming Contest cases.

Input Every te
The input contains one string s , the name of your friend
marks.
Output
The output should be "Aleppo" (without quotes) Each of

input the -th


ahmad Outpu
output For eve
score o
Aleppo

input
input
1
hossain 2
output 1 2 3
10 3 4
Aleppo
outpu
36
B. Marks 45

1 second, 1024 megabytes


Given an array consists integer numbers. Given a

Let be the product of all elements of array . you nee


elemen
Print "Positive" if is a positive number. right of
Print "Negative" if is a negative number.
Print "Zero" if is equal to . Input
The firs
Input The nex
The first line contains an integer . the size of array .
The
The second line contains integers
the arra
elements of array .
The
Output
Print the answer as specified above.
Outpu
input Print "Y
"NO".
5
1 9 2 6 -1
input
output
2
Negative 3
1 2 3
input 4
1 2 3
3
6 4 5 outpu
output NO
YES
Positive

input
input
3
4 5
0 1 2 3 1 1 4
4
output 2 0 0
Zero 4
0 0 2

D. Balance The Array


1 second, 256 megabytes
output outpu
YES 3
YES
YES
input
5
E. Min Cost ababa
10 5 1
1 second, 256 megabytes
outpu
A string is called beautiful if there doesn't exist any two equal characters 0
adjacent to each other. In the fi
Given a string consists only of lowercase English letters and you should .
delete some characters to make beautiful. In the s
The cost of deleting the character on the index is equal to . .

Print the minimum cost to make string beautiful. In the th

Input
The first line contains an integer the size of string
.

The second line contains lowercase English letters represent string .


You are
The third line contains integers . balance

In one o
Output
Print the minimum cost to make string beautiful. First let
follows
input
6
1. The
abccbd
0 1 2 3 4 5
2. The

output 3. The

2
Input
Only on
input
6
aabbcc Outpu
1 2 1 2 1 2 Output
string b
input Baby C
your tur
())
Input
output The firs
1 The sec

input All char

()() Outpu
Print the
output
0 If there

You can't change the order or swap any elements in the string. input
earth
heart
G. Baby Conan and anagrams
outpu
1 s., 256 MB
earth

input
thesch
trsmso

outpu
thecla

Artem is
String is an anagram of string , if we can rearrange the letters in string able to
and get exact string . For example, strings "DOG" and "GOD" are put a lo
anagrams, so are strings "ABA" and "AAB", but strings "ABBAC" and first cuc
"CAABA" are not. problem

Baby Conan is learning anagrams, so he will play a computer game. In


this game there are two strings , . To win in this game Conan has to
print the largest lexicographical substring of that is an anagram of string
. if there are no valid substrings he has to print -1.
To be more specific, the th ( ) cuckoo clock will make a input
sound every minutes after their synchronized sound. For example, for
3
the clock will keep emitting sounds every minutes after
1000 6
it's first cuckoo at time . So Artem will be able to listen to it's beautiful 100000
sound on the minutes. 100000

Excited for all of his hard work, Artem wants to show the experiment to his outpu
grandma. Currently it's time and he knows that his grandma will be back 8
from the store in minutes. Artem wants you to help him figure out how 4
many clocks will make their cuckoo sound exactly when his grandma 20
arrives!
Input
The first line contains an integer — the number of test
cases.

For each test case, the only line contains two integers — As a ne
and , for the number of cuckoo Associa
clocks and the time in minutes when Artem's grandma is back, year. O
respectively. differen
Moreov
Output for ea
For each test case, output the number of clocks that make the cuckoo
sound at exactly minutes. In addit
problem
input that pro
5 Natural
5 1
contest
10 5
10 6 single c
5 3 than on
6 11
The AA
output the AAP
5 equal to
3 as man
2
2 Using th
3
number

Input
The firs
the num
Then, a second line with integers , where each In the fi
indicates the number of problems assigned to level problem
that a contest organized by the AAPC must have. at their
be assig
Finally, a third line with integers , where
of co
denotes the number of problem proposals with a
grade of difficulty of that the AAPC has at their disposal to create the
desired contests.
Output
A single line with an integer that represents the maximum number of
contests that the AAPC can organize while attaining the required amount You will
of problems per level using the problems that they have at their disposal. each el
the max
input
Here is
5
2 2 2 2 2
100 0 0 0 0

output
10

input
5
2 3 2 2 2
10 0 9 3 1

output
2 if you c
then the
input
Input
5
The firs
2 3 2 2 2
0 100 7 0 6

output The sec


0 integers

Outpu
Only on
input George
conditio
9
1 8 6 2 5 4 8 3 7 Can yo
Input
output The firs
49 descrip

The firs
input
5
1 5 2 3 4 The sec
output
12 It is gua
.
input
Outpu
2 For eac
1 2

output input
1 1
6
1 2 3
K. Zero Hour outpu
1 second, 1024 megabytes 3

George enjoys playing old classic games. One day, he started playing the
popular game called "General Zero Hour" on his computer. While playing
the game, he encountered a problem and had to stop.

In the game, George has a certain number of soldiers, denoted by .


Each soldier is assigned a power level, denoted by . Now, George In the m
needs to divide these soldiers into groups, while adhering to the following of in
two conditions: tree rep
other vi
Each soldier should belong to exactly one group. unique
If two soldiers and belong to the same group, then the Bitwise
The wis
XOR value of their power levels should be greater than or equal to the
know w
minimum power level between them, In other words ( ) should
traveler
be greater than or equal to .
depend
paths a
You are given a tree with nodes (numbered from to ) and
edges. Each node in the tree represents a village.
In the la
Your task is to determine: number
of numb
1. The maximum number of times any single edge in the tree is visited.
pairs of
2. The number of edges that are visited exactly this number of times.
Input 1. Bot
The first line contains a single integer , the number of 2. The
nodes in the tree. digi
3. For
Each of the next lines contains two integers and
the
indicating there is an edge between nodes and .
4. Bot
Output
Print two integers. The first integer is the maximum number of times any You hav
single edge is visited. The second integer is the number of edges that are many p
visited exactly this number of times. number

Input
input The firs
7 queries
1 2
1 3 Each of
2 4 represe
2 5
3 6 Outpu
3 7 For eac
output pairs of
12 2 becaus

input input
1
5
2
1 2
2 3 outpu
3 4
4 5 480

output
input
6 2
2
3
4
M. Dueling Digits
output input
30612 10 5
2437704 abacda
7 10 0
5 8 1
N. A Simple Task 1 4 0
3 6 0
5 seconds, 512 megabytes 7 10 1

outpu
This task is very simple. Given a string S of length n and q queries each
query is on the format i j k which means sort the substring consisting of cbcaaa

the characters from i to j in non-decreasing order if k = 1 or in non-


increasing order if k = 0. input
10 1
Output the final string after applying the queries.
agjucb
1 10 1
Input
The first line will contain two integers n, q (1 ≤ n ≤ 105, 0 ≤ q ≤ 50 000), outpu
the length of the string and the number of queries respectively. abcdfg

Next line contains a string S itself. It contains only lowercase English


First sa
letters.

Next q lines will contain three integers each i, j, k (1 ≤ i ≤ j ≤ n,


).

Output
Output one line, the string S after applying the queries.

Codeforces (c) Copyright 2010-202


The only programming contests W

You might also like