Erfan.aa's blog

By Erfan.aa, 4 months ago, In English,

Greetings Codeforces community!

I am sure you have heard that CodeChef is celebrating 10 years of competitive programming!

I would like to invite you to compete in March Cook-Off, sponsored by ShareChat. The Cook-Off is 2.5 hours contest and offers 5 problems for you to try your hand at. And as CodeChef is celebrating its birthday, there are additional prizes up for grabs.

ShareChat- India’s fastest growing social network and sponsor of the contest is seeking talented programmers to join their team. Internships and full-time job opportunities are available for participants of the March Cook-Off. Visit the contest page for more details.

I hope you will join your fellow programmers and enjoy the contest problems. Joining me on the problem setting panel are:

  • Admin: kingofnumbers (Hasan Jaddouh)
  • Tester and Editorialist: Deadwing (Hussain Kara Fallah)
  • Statement Verifier: Xellos (Jakub Safin)
  • Setters: Erfan.aa (Erfan Alimohammadi), AminAnvari (Amin Anvari), Haghani (Ali Haghani), aliams (Ali Mirjahani), mrm_196 (Mohammad Reza Mohseni), farnasirim (Mohammad Nasirifar)
  • Mandarin Translator: huzecong (Hu Zecong)
  • Vietnamese Translator: Team VNOI
  • Russian Translator: Fedosik (Fedor Korobeinikov)
  • Bengali Translator: solaimanope (Mohammad Solaiman)
  • Hindi Translator: Akash Shrivastava

Contest Details:

  • Start Date & Time: 24th March 2019 (2130 hrs) to 25th March 2019 (0000 hrs). (Indian Standard Time — +5:30 GMT) — Check your timezone
  • Contest link: https://www.codechef.com/COOK104
  • Registration: You just need to have a CodeChef handle to participate. For all those, who are interested and do not have a CodeChef handle, are requested to register in order to participate.
  • Prizes: Top 10 performers in Global and Indian category will get CodeChef laddus, with which the winners can claim cool CodeChef goodies. As CodeChef is celebrating 10 years of cooking, there are additional laddus up for grabs. Know more about the additional prizes here: https://www.codechef.com/COOK104 and about the laddus here: https://www.codechef.com/laddu
    (For those who have not yet got their previous winning, please send an email to winners@codechef.com)

By the way, happy Nowruz!

Happy programming and have a great new year!

Good Luck!

Read more »

 
 
 
 
  • Vote: I like it
  • +70
  • Vote: I do not like it

By Erfan.aa, 7 months ago, In English,

Hello!

As you know, each team can have a notebook for their reference in any ACM-ICPC official contest. Actually, this is a rule of regional and World Finals ACM-ICPC contests, that you can bring some papers with yourself. Usually, each team put some source codes of different algorithms in their cheatsheet.

Generating this cheatsheet would be a little hard, because you may want to put many source codes in a few pages. Also, you may want to add a table of contents to it. And the most important part is to have syntax highlighting for your codes.

I just wanted to introduce you a tool for this purpose. Its name is "codes2pdf" and it's here: https://github.com/Erfaniaa/codes2pdf

(Actually, it's forked from pin3da/notebook-generator and it has been improved.)

Just give your cpp, py, java, and tex files as an input to it; it will generate a PDF file for you. Sample PDF file

I hope it will be helpful to you, even in fields which are not related to ACM-ICPC.

Read more »

 
 
 
 
  • Vote: I like it
  • +81
  • Vote: I do not like it

By Erfan.aa, 5 years ago, In English,

459A - Pashmak and Garden

Four vertices of a square with side length a (and sides parallel to coordinate axis) are in this form: (x0, y0), (x0 + a, y0), (x0, y0 + a), (x0 + a, y0 + a).

Two vertices are given, calculate the two others (and check the ranges).

Total complexity : O(1)

Sample solution: 7495194

459B - Pashmak and Flowers

If all numbers are equal then answer will be n * (n - 1) / 2, otherwise the answer will be cnt1 * cnt2, where cnt1 is the number of our maximum elements and cnt2 is the number of our minimum elements.

Total complexity : O(n)

Sample solution: 7495202

459C - Pashmak and Buses

For each student consider a sequence of d elements from 1 to k that shows the bus number which is taken by this student on each day. Obviously, there are kd different sequence at all, so if n > kd, pigeonhole principle indicates that at least two of this sequences will be equal, so that two students will become close friends and no solutions exist. But if n ≤ kd, then we can assign a unique sequence to each student and compute the answer. For computing that, we can find the first n d-digits numbers in k-based numbers.

Total complexity : O(n * d)

Sample solutions: 7495236

459D - Pashmak and Parmida's problem

First of all, we can map the given numbers to integers of range [1, 106]. Let li be f(1, i, ai) and let ri be f(i, n, ai), we want to find the number of pairs (i, j) such that i < j and li > rj. For computing lis, we can store an array named cnt to show the number of occurence of any i with cnt[i]. To do this, we can iterate from left to right and update cnt[i]s; also, li would be equal to cnt[ai] at position i (ri s can be computed in a similar way).

Beside that, we get help from binary-indexed trees. We use a Fenwick tree and iterate from right to left. In each state, we add the number of elements less than li to answer and add ri to the Fenwick tree.

Total complexity : O(n * logn)

Also we can solve this problem using divide and conquer method. You can see the second sample solution to find out how to do this exactly.

Sample solutions: 7495225 7495225

459E - Pashmak and Graph

In this problem, a directed graph is given and we have to find the length of a longest strictly-increasing trail in it.

First of all consider a graph with n vertices and no edges, then just sort the given edges by their weights (non-decreasingly) and add them to the graph one by one.

Let dp[v] be the length of a longest increasing trail which ends in the vertex v. In the mentioned method, when you're adding a directed edge xy to the graph, set dp[y] value to max(dp[y], dp[x] + 1) (because of trails which ends in y and use this edge). You need to take care of the situation of being some edges with equal weights; for this job we can add all edges of the same weights simultaneously.

Total complexity : O(n + m * logm)

Sample solution: 7495216

Read more »

 
 
 
 
  • Vote: I like it
  • +46
  • Vote: I do not like it

By Erfan.aa, 5 years ago, In English,

Hello everybody!

I just want to invite you to participate in Codeforces Round #261 (Div.2 only), which will be held on August 15th, 19:30MSK.

This round is prepared by ShayanH, Haghani and me. Special thanks to mruxim for helping us to prepare the problems. Actually, this is our first round and we hope you'll enjoy the contest.

Traditionally, we thank Gerald for helping us to get the contest prepared and also MikeMirzayanov, for the great Polygon system.

Main characters of our stories are two interesting persons, named "Pashmak" and "Parmida"; such a lovely couple! <3

Score distribution will be announced soon.

Have fun. ;)

UPD1: Dynamic scoring system will be used.

UPD2: We recommend you to read all problems, although they're sorted by their estimated difficulty.

UDP3: We also thank Aksenov239 who helped us a lot in fixing the Russian statements.

UDP4: It's over!

Congratulations to all people who solved the five problems.

These are the 7 top official contestants:

  1. vanhanh.pham

  2. ElemeNtLz

  3. MLboy

  4. mssjtxwd

  5. yyfkiller3

  6. phidang

  7. roben_76

Editorial will be published soon.

UDP5: We're sorry for the delay. We put a brief editorial here.

Read more »

Statements of RDFZ Tournament #1
 
 
 
 
  • Vote: I like it
  • +163
  • Vote: I do not like it

By Erfan.aa, 5 years ago, In English,

I found a really small bug in Codeforces profiles. It's funny, try it:

  1. Navigate to your own profile.
  2. Go to settings.
  3. Click on "Save changes" button.
  4. Go back to your profile and check your last visit time!

You'll face this funny bug:

This bug isn't an annoying one, but I hope my post will help admins in improving Codeforces. :)

Read more »

 
 
 
 
  • Vote: I like it
  • +133
  • Vote: I do not like it

By Erfan.aa, 6 years ago, In English,

7th programming contest of Allame Helli high school is about to begin shortly.

For more info check http://hellinet.ir.

Registration is available for pupils in Iran.

For registration: http://hellinet.ir/regtype.php

Good luck. ;)

Read more »

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

By Erfan.aa, 6 years ago, In English,

Hey guys! I've found something strange about the Codeforces judge. Please read this submission: 3373203 (for problem C) (with n <= 3 * 10^5 and -10^9 <= a[i] <= 10^9)

I think the verdict for this submission should be "TLE" because of its O(answer) algorithm. Answer for this problem can be as large as 10^13. (During the contest, I hacked this submission twice and got "Unsuccessful hacking attempt" (and -100 points!))

Am I wrong? Is the code judged correctly?

Read more »

 
 
 
 
  • Vote: I like it
  • +12
  • Vote: I do not like it