Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Guidelines to Write Experiences
  • Write Interview Experience
  • Write Work Experience
  • Write Admission Experience
  • Write Campus Experience
  • Write Engineering Experience
  • Write Coaching Experience
  • Write Professional Degree Experience
  • Write Govt. Exam Experiences
Open In App
Next Article:
Contest Experiences | Codeforce Round: #871 (Div. 4)
Next article icon

Contest Experiences | Codeforce Round: #871 (Div. 4)

Last Updated : 30 Oct, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

About the contest:

The contest was organized by Codeforces on May 6, 2023. It consisted of 8 questions and the time given to solve them was 2 hours 30 minutes i.e. 150 mins.

Link of the Contest: Codeforces Round #871 (Div 4)

Overview of the Questions

Problem Name

Difficulty

Pre-Requisite

Time to Solve by Me

Number of Attempts

Love Story

Easy (800)

Implementation, Strings

2 mins

1

Blank Space

Easy (800)

Implementation

5 mins

1

Mr. Perfectly Fine

Easy (800)

Implementation, Greedy

9 mins

1

Gold Rush

Easy (1000)

brute force, dfs and similar, dp

17 mins

2

The Lakes

Medium (1100)

graphs, dsu, dfs and similar

32 mins

1

Forever Winter

Medium (1300)

dfs and similar, graphs, math

48 mins

3

Hits Different

Hard (1600)

data structures, math, dp

47+ mins

-

Don't Blame Me

Hard (1700)

bitmasks, combinatorics, dp, math

-

-

EXPERIENCE:

Problem A: Love Story

My Experience: Like usual Div 4 contests, the first 2-3 questions are pure implementation based. This was a cakewalk problem which could be easily solved even by beginners in a few minutes.

Accepted Solution:

Simply follow the instructions given in problem. Initialize a string temp = "codeforces" and simply count the number of indexes where s[i] != temp[i]. The time complexity of the code will be O(N).

Problem B: Blank Space

My Experience: This question was also implementation based. One had to simply follow the instructions as mentioned in the problem statement and the question could be solved within 5 mins.

Accepted Solution:

The Approach to the question was very easy. Simply count the number of consecutive 0's in the array. The segment with maximum number of consecutive 0's will be the answer. The time complexity for each test case will be O(N).

Problem C: Mr. Perfectly fine

My Experience: This was a greedy question which required simple conditional statements. Initially I tried to use extra space, but during the coding part, I realized it could even be solved without using extra space by just using 3 variables and it got accepted.

Accepted Solution:

The approach was to find the minimum time to collect each of "11", "10" and "01" strings. Let minimum time to collect "11" be a, "10" be b and "01" be c. Both skills could be gathered either through "11" or combination of "01" and "10". Hence, the answer will be simply min(a, b + c). In case the answer comes out to be INT_MAX, we will return -1. The time complexity for each test case will be O(N).

Problem D: Gold Rush

My Experience: This was a pure mathematics related problem. I tried to understand the test cases but it didn't helped that much. Later, I created my own test cases and found out the pattern that how can we divide a number into 2 numbers such that one is double of another. From this pattern I got the approach for using recursion in this problem. Although I missed an edge case that the number should be divisible by 3, therefore I got a WA.

Accepted Solution:

If you divide a number into 2 numbers such that one number is the double of other (like 6 => 2 + 4), then one number will be 1/3rd of the original number and the other number will be 2/3rd of the original number. (1/3rd of 6 => 2 & 2/3rd of 6 => 4). This forms the recurrence relation that if using either of the relation, we can reach the number 'm' then we return "YES" else we return "NO". The base case will be if n < m or n % 3 != 0, then simply return false. The time complexity for each test case will be O(n log32).

Problem E: The Lakes

My Experience: Being honest, I expected a gradual increase in the difficulty for of problem from D to E, but against my expectation, the problem E was a standard island problem in graph theory using BFS/DFS. I had solved similar type of problems on other practice websites before so I started coding instantly just after looking at the first test case. I was delighted that it got accepted in the first try itself.

Accepted Solution:

My approach to this problem was using DFS. I ran a loop for every cell of the matrix and every time I find a non zero number (lake body), I perform DFS for that volume. Make sure to mark the cells of the lake visited so that it may not get added in the areas of any other lake volumes. The edge cases were simply boundary conditions where the index must be within the boundaries of matrix and the cell must be a Non zero cell. We simultaneously keep track of the maximum volume of lake encountered so far. At the end we simply return the maximum volume. The time complexity to solve this question was O(mn).

Problem F: Forever Winter

My Experience: As soon as I read the description of the problem I realized that it was yet another graph problem because nodes and vertices were mentioned along with graph like figure. however, I saw that pattern of graph problem for the first time. The question was straight forward, but the challenging part was to identify an approach to solve it. I tried to recall all the concepts about graph theory and identify which one could be used to solve this problem. Since it required counting the number of connections of each node, I tried to approach it using indegree and outdegree array concept but it gave WA. However, making my own test cases for the problem helped a lot to analyze the relation between x and y in snowflake graph.

Accepted Solution:

It is very obvious that the central node/vertex of the snowflake will have the most number of connections among all the nodes in the entire graph. We need to find the degree of each vertex and store it in a degree vector. After this, we make a hashmap which will store the count of each degree of non-leaf nodes in the graph. Let the number of branches in the snowflake from central vertex be 5 and number of branches from individual non-leaf non-central vertex be 3, then the map will look like this: {3 : 5, 5 : 1} (because there are 5 nodes with 3 branches and 1 central node with 5 branches). Hence, using this map we can simply declare 5 as X (because there is only 1 central node in the graph and the central node will always have maximum branches). Now, Y could be easily figured out using the relation map[degree_count] >= 2. This is because all the leaf nodes will have degree 1 and central vertex's map value is also 1. Hence, the value of Y will be equal to the degree_count. The time complexity of this solution for each test case will be O(n + m).

Problem G: Hits Different

My Experience: Being honest, my adrenaline was at peak when problem F got accepted. Although I knew, I had got several penalties and took more time for F problem. The first moment I read problem G, I thought it would be an advanced math problem. Although after the contest ended, I got to know that it was a DP problem which was supposed to be solved using precomputation. The problem statement was very short, but it was challenging to identify what approach to use in it. I thought to find a relation between sum of individual layers in the pyramid. However, the constraints to this problem were 10^6 which meant that it was supposed to be solved in O(n) time complexity. I struggled with the problem for the rest of the duration of the contest. At the end, I was unable to find an approach for the problem.

Conclusion

Like usual Div 4 contests, the first 3-4 problems were pure implementation based which didn't required use of any data structure and algorithm concept. The problems G and H were very challenging and difficult. Overall it was a great contest for me, I ended up solving 6/8 problems. This contest was not focused on just one or two concepts of DSA, but rather it had several varieties of problems covered like Math, Graph, DP, DSU, Sorting, Combinatorics, Bitmasking, etc. The learnings from from this contest was that one must solve different patterns of problems from every topic and not just standard problems. Also, one cannot blindly assume the problems to come from regular topics, they may come from rare topics like combinatorics, dsu, segment tree, trie, etc.


Next Article
Contest Experiences | Codeforce Round: #871 (Div. 4)

O

oxygen
Improve
Article Tags :
  • Contest Experiences
  • Codeforces-Contests

Similar Reads

    Contest Experiences | Codeforce Round: #870 (Div. 2)
    ABOUT THE CONTEST: This contest was organized by Codeforces on May 5th, 2023. It consisted of 6 questions and the time given to solve them was 2 hours. Such contests Codeforces platform serve as a proving ground for algorithmic prowess and problem-solving skills. Prizes/Offers:While tangible prizes
    3 min read
    Contest Experiences | Codeforce Round: #876 (Div. 2)
    About the contest: This contest was conducted by codeforces #876 for Div 2 Participants.In this contest, there are a total of 5 problems, and 2 hours and 15 minutes time given to solve this problem.The penalty was 10 minutes for each wrong submission.Link of the Contest: https://codeforces.com/conte
    3 min read
    Contest Experiences | Codeforce Round: #874 (Div. 3)
    ABOUT THE CONTEST: This contest was conducted by codeforces #874 for Div 3 Participants.In this Contest, there are 7 problems, and 2 hours and 15 minutes are given to solve this problem.For each wrong 10 minutes extra penalty problems.Link of the Contest: https://codeforces.com/contest/1833 My Exper
    3 min read
    Contest Experience: Codeforces Round 891 (Div. 3)
    About The Contest: This Contest was organized on 7 August 2023 on Codeforces. The Contest consisted of 7 problems and had a duration of 2 hours and 15 minutes. The contest had around 40k registrations which was the most for any Div 3 contest till now on Codeforces. Contest Link: Codeforces Round 891
    4 min read
    Contest Experiences | Codeforce Round: #872 (Div. 1 & 2)
    Codeforces organized 'Codeforces Round 872' for Div 1 and Div 2 on 8th May, 2023. The round was rated for all participants. The pattern of the contest was that it had 5 problems, one of which was divided into two subtasks. Each division was given 2 hours of time to solve them. The contest had some r
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences