/Codeforces_Solution

Program codes for a wide range of Codeforces problem

Primary LanguageC++

Codeforces_Solution

Program codes for a wide range of Codeforces problem (constantly updating)

PROBLEMS

  • 53-C: Little Frog
  • 71-C: Round Table Knights
  • 121-A: Lucky Sum
  • 126-B: Password
  • 242-C: King's Path
  • 257-C: View Angle
  • 264-B: Good Sequences
  • 269-B: Greenhouse Effect
  • 271-D: Good Substrings
  • 295-B: Greg and Graph
  • 329-A: Purification
  • 375-B: Maximum Submatrix 2
  • 407-A: Triangle
  • 407-B: Long Path
  • 429-B: Working out
  • 451-D: Count Good Substrings
  • 478-D: Red-Green Towers
  • 484-B: Maximum Value
  • 487-A: Fight the Monster
  • 510-D: Fox And Jumping
  • 520-B: Two Buttons
  • 609-E: Minimum spanning tree for each edge
  • 767-A: Snacktower
  • 767-B: The Queue
  • 777-D: Cloud of Hashtags
  • 869-A: The Artful Expedient
  • 869-B: The Eternal Immortality
  • 869-C: The Intriguing Obsession
  • 913-D: Too Easy Problems
  • 919-D: Substring
  • 925-B: Resource Distribution
  • 957-D: Riverside Curio
  • 1010-B: Rocket
  • 1016-C: Vasya And The Mushrooms
  • 1036-C: Classy Numbers
  • 1059-D: Nature Reserve
  • 1061-C: Multiplicity
  • 1070-A: Find a Number
  • 1073-C: Vasya and Robot
  • 1083-A: The Fair Nut and the Best Path
  • 1089-A: Alice the Fan
  • 1091-C: New Year and the Sphere Transmission
  • 1092-D1: Great Vova Wall (Version 1)
  • 1092-D2: Great Vova Wall (Version 2)
  • 1097-A: Gennady and a Card Game
  • 1097-B: Petr and a Combination Lock
  • 1097-C: Yuhao and a Parenthesis
  • 1097-D: Makoto and a Blackboard
  • 1100-A: Roman and Browser
  • 1100-B: Build a Contest
  • 1100-C: NN and the Optical Illusion
  • 1100-E: Andrew and Taxi
  • 1101-A: Minimum Integer
  • 1101-B: Accordion
  • 1101-C: Division and Union
  • 1101-D: GCD Counting
  • 1101-E: Polycarp's New Job
  • 1102-A: Integer Sequence Dividing
  • 1102-B: Array K-Coloring
  • 1102-C: Doors Breaking and Repairing
  • 1102-D: Balanced Ternary String
  • 1102-E: Monotonic Renumeration
  • 1102-F: Elongated Matrix
  • 1103-B: Game with modulo
  • 1105-D: Kilani and the Game
  • 1105-E: Helping Hiasat
  • 1106-A: Lunar New Year and Cross Counting
  • 1106-B: Lunar New Year and Food Ordering
  • 1106-C: Lunar New Year and Number Division
  • 1106-D: Lunar New Year and a Wander
  • 1106-E: Lunar New Year and Red Envelopes
  • 1107-A: Digits Sequence Dividing
  • 1107-B: Digital root
  • 1107-C: Brutality
  • 1107-D: Compression
  • 1108-A: Two distinct points
  • 1108-B: Divisors of Two Integers
  • 1108-C: Nice Garland
  • 1108-D: Diverse Garland
  • 1108-E1: Array and Segments (Easy version)
  • 1108-E2: Array and Segments (Hard version)
  • 1108-F: MST Unification
  • 1110-A: Parity
  • 1110-B: Tape
  • 1110-C: Meaningless Operations
  • 1110-D: Jongmah
  • 1110-E: Magic Stones
  • 1111-A: Superhero Transformation
  • 1111-B: Average Superhero Gang Power
  • 1111-C: Creative Snap
  • 1113-A: Sasha and His Trip
  • 1113-B: Sasha and Magnetic Machines
  • 1113-C: Sasha and a Bit of Relax
  • 1113-D: Sasha and One More Name
  • 1114-A: Got Any Grapes?
  • 1114-B: Yet Another Array Partitioning Task
  • 1114-C: Trailing Loves (or L'oeufs?)
  • 1114-D: Flood Fill
  • 1114-E: Arithmetic Progression
  • 1117-A: Best Subsegment
  • 1117-B: Emotes
  • 1117-C: Magic Ship
  • 1117-D: Magic Gems
  • 1117-E: Decypher the String
  • 1118-A: Water Buying
  • 1118-B: Tanya and Candies
  • 1118-C: Palindromic Matrix
  • 1118-D1: Coffee and Coursework (Easy version)
  • 1118-D2: Coffee and Coursework (Hard Version)
  • 1119-A: Ilya and a Colorful Walk
  • 1119-B: Alyona and a Narrow Fridge
  • 1119-E: Pavel and Triangles
  • 1120-A: Diana and Liana
  • 1120-C: Compress String
  • 1129-B: Wrong Answer
  • 1131-A: Sea Battle
  • 1131-B: Draw!
  • 1131-C: Birthday
  • 1131-D: Gourmet choice
  • 1132-F: Clear the String
  • 1133-F2: Spanning Tree with One Fixed Degree
  • 1136-A: Nastya Is Reading a Book
  • 1136-B: Nastya Is Playing Computer Games
  • 1136-C: Nastya Is Transposing Matrices
  • 1138-A: Sushi for Two
  • 1138-B: Circus
  • 1138-C: Skyscrapers
  • 1138-D: Camp Schedule
  • 1139-A: Even Substrings
  • 1139-B: Chocolates
  • 1139-C: Edgy Trees
  • 1140-A: Detective Book
  • 1140-B: Good String
  • 1140-C: Playlist
  • 1140-D: Minimum Triangulation
  • 1140-E: Palindrome-less Arrays
  • 1141-A: Game 23
  • 1141-B: Maximal Continuous Rest
  • 1141-C: Polycarp Restores Permutation
  • 1141-D: Colored Boots
  • 1141-E: Superhero Battle
  • 1141-F1: Same Sum Blocks (Easy)
  • 1141-F2: Same Sum Blocks (Hard)
  • 1141-G: Privatization of Roads in Treeland
  • 1142-B: Lynyrd Skynyrd
  • 1144-E: Median String
  • 1146-D: Frog Jumping
  • 1147-B: Chladni Figure
  • 1147-C: Thanos Nim
  • 1149-B: Three Religions
  • 1151-C: Problem for Nazar
  • 1151-E: Number of Components
  • 1152-D: Neko and Aki's Prank
  • 1153-D: Serval and Rooted Tree
  • 1153-E: Serval and Snake
  • 1154-F: Shovels Shop
  • 1154-G: Minimum Possible LCM
  • 1155-D: Beautiful Array
  • 1155-E: Guess the Root
  • 1156-C: Match Points
  • 1156-D: 0-1-Tree
  • 1156-E: Special Segments of Permutation
  • 1157-D: N Problems During K Days
  • 1157-F: Maximum Balanced Circle
  • 1157-G: Inverse of Rows and Columns
  • 1158-A: The Party and Sweets
  • 1158-B: The minimal unique substring
  • 1158-C: Permutation recovery
  • 1163-C1: Power Transmission (Easy Edition)
  • 1163-C2: Power Transmission (Hard Edition)
  • 1163-D: Mysterious Code
  • 1165-F1: Microtransactions (easy version)
  • 1165-F2: Microtransactions (hard version)
  • 1166-D: Cute Sequences
  • 1166-E: The LCMs Must be Large
  • 1167-E: Range Deleting
  • 1168-A: Increasing by Modulo
  • 1168-B: Good Triple
  • 1168-C: And Reachability
  • 1172-B: Nauuo and Circle
  • 1174-D: Ehab and the Expected XOR Problem
  • 1175-D: Array Splitting
  • 1175-E: Minimal Segment Cover
  • 1176-F: Destroy it!
  • 1177-B: Digits Sequence (Hard Edition)
  • 1178-E: Archaeology
  • 1178-F1: Short Colorful Strip
  • 1179-C: Serge and Dining Room
  • 1181-C: Flag
  • 1181-D: Irrigation
  • 1183-F: Topforces Strikes Back
  • 1183-G: Candy Box (hard version)
  • 1183-H: Subsequences (hard version)
  • 1184-A2: Heidi Learns Hashing (Medium)
  • 1184-B2: The Doctor Meets Vader (Medium)
  • 1184-C2: Heidi and the Turing Test (Medium)
  • 1184-E1: Daleks' Invasion (easy)
  • 1184-E2: Daleks' Invasion (medium)
  • 1185-E: Polycarp and Snakes
  • 1185-F: Two Pizzas
  • 1185-G1: Playlist for Polycarp (easy version)
  • 1187-E: Tree Painting
  • 1190-D: Tokitsukaze and Strange Rectangle
  • 1194-E: Count The Rectangles
  • 1195-E: OpenStreetMap
  • 1196-F: K-th Path
  • 1197-D: Yet Another Subarray Problem
  • 1198-C: Matching vs Independent Set
  • 1200-D: White Lines
  • 1200-E: Compress Words
  • 1201-B: Zero Array
  • 1201-D: Treasure Hunting
  • 1202-C: You Are Given a WASD-string...
  • 1202-D: Print a 1337-string...
  • 1203-D2: Remove the Substring (hard version)
  • 1203-F1: Complete the Projects (easy version)
  • 1204-D1: Kirk and a Binary String (easy version)
  • 1204-D2: Kirk and a Binary String (hard version)
  • 1205-B: Shortest Cycle
  • 1207-E: XOR Guessing
  • 1207-F: Remainder Problem
  • 1208-D: Restore Permutation
  • 1208-E: Let Them Slide
  • 1209-E1: Rotate Columns (easy version)
  • 1209-G1: Into Blocks (easy version)
  • 1210-C: Kamil and Making a Stream
  • 1213-D2: Equalizing by Division (hard version)
  • 1213-E: Two Small Strings
  • 1213-F: Unstable String Sort
  • 1214-D: Treasure Island
  • 1214-E: Petya and Construction Set
  • 1215-E: Marbles
  • 1216-A: Prefixes
  • 1216-B: Shooting
  • 1216-D: Swords
  • 1216-E1: Numerical Sequence (easy version)
  • 1216-E2: Numerical Sequence (hard version)
  • 1216-F: Wi-Fi
  • 1217-D: Coloring Edges
  • 1218-I: The Light Square
  • 1219-G: Harvester
  • 1220-D: Alex and Julian
  • 1220-E: Tourism
  • 1223-D: Sequence Sorting
  • 1223-E: Paint the Tree
  • 1225-E: Rock Is Push
  • 1227-E: Arson In Berland Forest
  • 1227-F1: Wrong Answer on test 233 (Easy Version)
  • 1227-F2: Wrong Answer on test 233 (Hard Version)
  • 1228-D: Complete Tripartite
  • 1231-E: Middle-Out
  • 1234-E: Special Permutations
  • 1234-F: Yet Another Substring Reverse
  • 1236-C: Labs
  • 1236-D: Alice and the Doll
  • 1237-C2: Balanced Removals (Harder)
  • 1237-D: Balanced Playlist
  • 1238-D: AB-string
  • 1238-E: Keyboard Purchase
  • 1238-F: The Maximum Subtree
  • 1242-B: 0-1 MST
  • 1244-C: The Football Season
  • 1244-E: Minimizing Difference
  • 1245-D: Shichikuji and Power Grid
  • 1247-A: Forgetting Things
  • 1247-B1: TV Subscriptions (Easy Version)
  • 1247-B2: TV Subscriptions (Hard Version)
  • 1247-C: p-binary
  • 1248-A: Integer Points
  • 1248-B: Grow The Tree
  • 1248-C: Ivan the Fool and the Probability Theory
  • 1248-D1: The World Is Just a Programming Task (Easy Version)
  • 1249-A: Yet Another Dividing into Teams
  • 1249-B1: Books Exchange (easy version)
  • 1249-B2: Books Exchange (hard version)
  • 1249-C1: Good Numbers (easy version)
  • 1249-C2: Good Numbers (hard version)
  • 1249-D1: Too Many Segments (easy version)
  • 1249-D2: Too Many Segments (hard version)
  • 1249-E: By Elevator or Stairs?
  • 1249-F: Maximum Weight Subset
  • 1250-C: Trip to Saint Petersburg
  • 1250-N: Wires
  • 1251-A: Broken Keyboard
  • 1251-B: Binary Palindromes
  • 1251-C: Minimize The Integer
  • 1251-D: Salary Changing
  • 1252-E: Songwriter
  • 1252-G: Performance Review
  • 1252-K: Addition Robot
  • 1253-E: Antenna Coverage
  • 1254-B1: Send Boxes to Alice (Easy Version)
  • 1254-B2: Send Boxes to Alice (Hard Version)
  • 1256-C: Platforms Jumping
  • 1256-E: Yet Another Division Into Teams
  • 1256-F: Equalizing Two Strings
  • 1257-E: The Contest
  • 1260-D: A Game with Traps
  • 1263-E: Editor
  • 1264-B: Beautiful Sequence
  • 1265-E: Beautiful Mirrors
  • 1266-D: Decreasing Debts
  • 1266-E: Spaceship Solitaire
  • 1267-K: Key Storage
  • 1269-D: Domino for Young
  • 1270-D: Strange Device
  • 1271-D: Portals
  • 1271-E: Common Number
  • 1272-E: Nearest Opposite Parity
  • 1272-F: Two Bracket Sequences
  • 1276-B: Two Fairs
  • 1277-D: Let's Play the Words?
  • 1278-D: Segment Tree
  • 1278-E: Tests for problem D
  • 1280-C: Jeremy Bearimy
  • 1283-E: New Year Parties
  • 1283-F: DIY Garland
  • 1284-D: New Year and Conference
  • 1285-D: Dr. Evil Underscores
  • 1288-C: Two Arrays
  • 1288-D: Minimax Problem
  • 1288-E: Messenger Simulator
  • 1294-E: Obtain a Permutation
  • 1294-F: Three Paths on a Tree
  • 1295-E: Permutation Separation
  • 1296-E2: String Coloring (hard version)
  • 1296-F: Berland Beauty
  • 1299-C: Water Balance
  • 1301-A: Three Strings
  • 1301-B: Motarack's Birthday
  • 1301-C: Ayoub's function
  • 1301-D: Time to Run
  • 1303-A: Erasing Zeroes
  • 1303-B: National Project
  • 1303-C: Perfect Keyboard
  • 1303-D: Fill The Bag
  • 1303-E: Erase Subsequences
  • 1304-A: Two Rabbits
  • 1304-B: Longest Palindrome
  • 1304-C: Air Conditioner
  • 1304-D: Shortest and Longest LIS
  • 1304-E: 1-Trees and Queries
  • 1305-A: Kuroni and the Gifts
  • 1305-B: Kuroni and Simple Strings
  • 1305-C: Kuroni and Impossible Calculation
  • 1305-D: Kuroni and the Celebration
  • 1305-E: Kuroni and the Score Distribution
  • 1307-A: Cow and Haybales
  • 1307-B: Cow and Friend
  • 1307-C: Cow and Message
  • 1307-D: Cow and Fields
  • 1311-A: Add Odd or Subtract Even
  • 1311-B: WeirdSort
  • 1311-C: Perform the Combo
  • 1311-D: Three Integers
  • 1311-E: Construct the Binary Tree
  • 1311-F: Moving Points
  • 1312-A: Two Regular Polygons
  • 1312-B: Bogosort
  • 1312-C: Adding Powers
  • 1312-D: Count the Arrays
  • 1312-E: Array Shrinking
  • 1313-C2: Skyscrapers (hard version)
  • 1316-A: Grade Allocation
  • 1316-B: String Modification
  • 1316-C: Primitive Primes
  • 1316-D: Nash Matrix
  • 1320-C: World of Darkraft: Battle for Azathoth
  • 1321-A: Contest for Robots
  • 1321-B: Journey Planning
  • 1321-C: Remove Adjacent
  • 1323-A: Even Subset Sum Problem
  • 1323-B: Count Subrectangles
  • 1323-C: Unusual Competitions
  • 1323-D: Present
  • 1324-A: Yet Another Tetris Problem
  • 1324-B: Yet Another Palindrome Problem
  • 1324-C: Frog Jumps
  • 1324-D: Pair of Topics
  • 1324-E: Sleeping Schedule
  • 1325-A: EhAb AnD gCd
  • 1325-B: CopyCopyCopyCopyCopy
  • 1325-C: Ehab and Path-etic MEXs
  • 1325-D: Ehab the Xorcist
  • 1326-A: Bad Ugly Numbers
  • 1326-B: Maximums
  • 1326-C: Permutation Partitions
  • 1326-D1: Prefix-Suffix Palindrome (Easy version)
  • 1327-C: Game with Chips
  • 1327-D: Infinite Path
  • 1328-D: Carousel
  • 1328-E: Tree Queries
  • 1328-F: Make k Equal
  • 1329-A: Dreamoon Likes Coloring
  • 1332-E: Height All the Same
  • 1333-D: Challenges in school №41
  • 1333-F: Kate and imperfection
  • 1334-D: Minimum Euler Cycle
  • 1334-E: Divisor Paths
  • 1335-E2: Three Blocks Palindrome (hard version)
  • 1335-F: Robots on a Grid
  • 1336-A: Linova and Kingdom
  • 1336-C: Kaavi and Magic Spell
  • 1338-B: Edge Weight Assignment
  • 1338-C: Perfect Triples
  • 1340-B: Nastya and Scoreboard
  • 1342-D: Multiple Testcases
  • 1343-D: Constant Palindrome Sum
  • 1343-E: Weights Distributing
  • 1345-A: Puzzle Pieces
  • 1345-B: Card Constructions
  • 1345-C: Hilbert's Hotel
  • 1345-D: Monopole Magnets
  • 1348-C: Phoenix and Distribution
  • 1348-D: Phoenix and Science
  • 1349-B: Orac and Medians
  • 1349-C: Orac and Game of Life
  • 1353-A: Most Unstable Array
  • 1353-B: Two Arrays And Swaps
  • 1353-C: Board Moves
  • 1353-D: Constructing the Array
  • 1353-E: K-periodic Garland
  • 1353-F: Decreasing Heights
  • 1354-A: Alarm Clock
  • 1354-B: Ternary String
  • 1354-C1: Simple Polygon Embedding
  • 1354-C2: Not So Simple Polygon Embedding
  • 1354-D: Multiset
  • 1354-E: Graph Coloring
  • 1355-A: Sequence with Digits
  • 1355-B: Young Explorers
  • 1355-C: Count Triangles
  • 1355-D: Game With Array
  • 1355-E: Restorer Distance
  • 1358-A: Park Lighting
  • 1358-B: Maria Breaks the Self-isolation
  • 1358-C: Celex Update
  • 1358-D: The Best Vacation
  • 1359-A: Berland Poker
  • 1359-B: New Theatre Square
  • 1359-C: Mixing Water
  • 1359-D: Yet Another Yet Another Task
  • 1359-E: Modular Stability
  • 1360-A: Minimal Square
  • 1360-B: Honest Coach
  • 1360-C: Similar Pairs
  • 1360-D: Buying Shovels
  • 1360-E: Polygon
  • 1360-F: Spy-string
  • 1360-G: A/B Matrix
  • 1360-H: Binary Median
  • 1362-A: Johnny and Ancient Computer
  • 1362-B: Johnny and His Hobbies
  • 1362-C: Johnny and Another Rating Drop
  • 1362-D: Johnny and Contribution
  • 1362-E: Johnny and Grandmaster
  • 1363-A: Odd Selection
  • 1363-B: Subsequence Hate
  • 1363-C: Game On Leaves
  • 1363-D: Guess The Maximums
  • 1363-E: Tree Shuffling
  • 1364-A: XXXXX
  • 1364-B: Most socially-distanced subsequence
  • 1364-C: Ehab and Prefix MEXs
  • 1364-D: Ehab's Last Corollary
  • 1365-A: Matrix Game
  • 1365-B: Trouble Sort
  • 1365-C: Rotation Matching
  • 1365-D: Solve The Maze
  • 1365-E: Maximum Subsequence Value
  • 1365-F: Swaps Again
  • 1366-A: Shovels and Swords
  • 1366-B: Shuffle
  • 1366-C: Palindromic Paths
  • 1366-D: Two Divisors
  • 1366-E: Two Arrays
  • 1367-A: Short Substrings
  • 1367-B: Even Array
  • 1367-C: Social Distance
  • 1367-D: Task On The Board
  • 1367-E: Necklace Assembly
  • 1367-F1: Flying Sort (Easy Version)
  • 1368-A: C+=
  • 1368-B: Codeforces Subsequences
  • 1368-C: Even Picture
  • 1368-D: AND, OR and square sum
  • 1369-A: FashionabLee
  • 1369-B: AccurateLee
  • 1369-C: RationalLee
  • 1369-D: TediousLee
  • 1370-A: Maximum GCD
  • 1370-B: GCD Compression
  • 1370-C: Number Game
  • 1370-D: Odd-Even Subsequence
  • 1370-E: Binary Subsequence Rotation
  • 1371-A: Magical Sticks
  • 1371-B: Magical Calendar
  • 1371-C: A Cookie for You
  • 1371-D: Grid-00100
  • 1371-E1: Asterism (Easy Version)
  • 1371-E2: Asterism (Hard Version)
  • 1372-A: Omkar and Completion
  • 1372-B: Omkar and Last Class of Math
  • 1372-C: Omkar and Baseball
  • 1372-D: Omkar and Circle
  • 1373-A: Donut Shops
  • 1373-B: 01 Game
  • 1373-C: Pluses and Minuses
  • 1373-D: Maximum Sum on Even Positions
  • 1373-E: Sum of Digits
  • 1374-A: Required Remainder
  • 1374-B: Multiply by 2, divide by 6
  • 1374-C: Move Brackets
  • 1374-D: Zero Remainder Array
  • 1374-E1: Reading Books (easy version)
  • 1374-E2: Reading Books (hard version)
  • 1374-F: Cyclic Shifts Sorting
  • 1375-A: Sign Flipping
  • 1375-B: Neighbor Grid
  • 1375-C: Element Extermination
  • 1375-D: Replace by MEX
  • 1375-E: Inversion SwapSort
  • 1375-F: Integer Game
  • 1379-A: Acacius and String
  • 1379-B: Dubious Cyrpto
  • 1379-C: Choosing flowers
  • 1380-A: Three Indices
  • 1380-B: Universal Solution
  • 1380-C: Create The Teams
  • 1380-D: Berserk And Fireball
  • 1380-E: Merging Towers
  • 1381-A1: Prefix Flip (Easy Version)
  • 1381-A2: Prefix Flip (Hard Version)
  • 1381-B: Unmerge
  • 1381-C: Mastermind
  • 1383-A: String Transformation 1
  • 1383-B: GameGame
  • 1384-A: Common Prefixes
  • 1384-B1: Koa and the Beach (Easy Version)
  • 1384-B2: Koa and the Beach (Hard Version)
  • 1385-A: Three Pairwise Maximums
  • 1385-B: Restore the Permutation by Merger
  • 1385-C: Make It Good
  • 1385-D: a-Good String
  • 1385-E: Directing Edges
  • 1385-G: Columns Swaps