Блог пользователя ahmad_alghadban

Автор ahmad_alghadban, история, 3 года назад, По-английски

We would be happy to invite you to participate in 2023 ICPC HIAST Collegiate Programming Contest that was held on 17th July in Damascus, Syria.

The problems are authored and prepared by Zaher ,SaeedSabbagh, OmarAlzakout, Yaman_Alwaza, Abdulrahman27, Khaled_Mardini, Ahmad7_7, Ismail_Alrifai, yaser.harba, and me.

Thanks to Kaitokid and HeMoo for testing the contest.

And Special thanks to EleCursity for helping us to coordinate the contest onsite and his efforts to ensure that everything ran well.

We would love to hear your feedback on the problems in the comments section. Hope you enjoy solving the problems!

UPD: it seems that there were something wrong with time limit of problem A, We've updated the time limit and all accepted solutions were rejudged, We do really apology for that wrong but too many non accepted solution have passed tests which made the problem too silly compared to the intended solution, We advise to try to solve the problem with the intended solution since it has a nice idea.

  • Проголосовать: нравится
  • +105
  • Проголосовать: не нравится

»
3 года назад, скрыть # |
 
Проголосовать: нравится +21 Проголосовать: не нравится

wlak 3aaash

»
3 года назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

Waiting for this!

»
3 года назад, скрыть # |
 
Проголосовать: нравится +31 Проголосовать: не нравится

The problems are so interesting that I wish I can forget the problems and participate as a contestant :(

»
3 года назад, скрыть # |
 
Проголосовать: нравится +25 Проголосовать: не нравится

Big up!!

»
3 года назад, скрыть # |
 
Проголосовать: нравится +30 Проголосовать: не нравится

As a problem-setter, I can assure you that the problems are interesting and I encourage you to try solving them all.

»
3 года назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

Great problems from great people <3

»
3 года назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

As a problem setter, I assure you that there are many good problems. I highly encourage participants to share their valuable feedback. Happy problem-solving to all participants!

»
3 года назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

Interesting problems with a lot of new ideas!
Waiting for the editorial :D

»
3 года назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

To be honest, amazing problemset. I solved some with too much excitement. Thanks for this :)

»
3 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +17 Проголосовать: не нравится

What a contest!!

»
3 года назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

As a participant, I truly enjoyed solving the problems. I can assure you that you will find the problem set very interesting. Thanks all for your efforts.

»
3 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +4 Проголосовать: не нравится

i'm using sparse table for answering queries in o(1) in problem B but still getting TLE on test 25 , any hints ? :((

update: AC folks , thanks for the great problemset

»
3 года назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

Thank you all for a great problemset.

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Great contest!

Can anyone explain the solution of B as I get MLE/TLE when implementing NLog^2(N)?

  • »
    »
    3 года назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +7 Проголосовать: не нравится

    you can use priority_queue to get the max and divide it by its largest prime factor but it will still n.log^2(n). to get rid of priority_queue or set, i use a frequency array. first store for each number from 1 to 2e6 the largest prime factor using sieve in an array p. then lets store for each number from 1 to 2e6 the indices where it appears in the array using a vector. then iterate over this array of vectors from 2e6 to 1. if the current i is prime then sort the vector and set ans[v[j]]=t (where t is the time),otherwise move all elements of the vector to the vector i/p[i] (and increment the time while moving them). each element will be moved at most log(a[i]) times ,and the sort complexity overall is O(n.log(n)) since each element has exactly one final state in some prime index.so the total time complexity is O(n.log(n)). i hope this helps you :)

»
3 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

time for B too tight: https://ideone.com/6J3igi this passes in 2,9 sec (tle at 3) how can I improve it?

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    Your solution is N*log(N)*log(max a[i]). There is an N*(log(N) + log(max a[i])) solution which pretty much fits the time limit. I mean it wouldve been too easy jf the solution was that straight forward right?

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

The best solution i could think about at problem I was O(2^min(n0/lo,n1,l1) by inclusion exclusion which clearly did not pass. Can anyone here provide a hint/solution? thanks.

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    Hint 1
    Hint 2
    Hint 3

    I hope this helps you.

»
3 года назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

I can't find the solution. May I ask where the solution is?

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

problem K is interesting. Please anyone tell me how to solve K? thank you.

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    Notice that the strings are sorted. Therefore, we can perform a binary search on them. Now, we have only 26 characters, so in each query, we can iterate over all characters. Let's denote the target character as 'C'. First, we perform a binary search on the strings 'a' and 'b' to find the first joint occurrence of 'C', which we will call "first". Next, we find the last joint occurrence of 'C' in 'a' and 'b', denoted as "last".

    To calculate the answer, we add (last — first + 1) for each character and continue this process for all characters. Finally, we print the answer for each query.

»
3 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Could anyone kindly assist me in identifying the correct state for the DP solution in problem A? I attempted to solve it recursively using a map with a pair of int and a vector of size 10. The int for id, The vector is meant to keep track of the number of digits used.

My transition function involves two choices: either not taking the number or taking the number, adding its value, and updating its digits to my vector. However, if any digit becomes greater than or equal to 3, I avoid the recursive call since it leads to invalid recursion.

Unfortunately, this solution is inefficient and results in a Time Limit Exceeded (TLE) error on test case 11.

»
3 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

first , thx for the Interesting problem set

can any one help me in J

my idea is to assume that x is to the left,right or equal to MED then

1)find MED

2)calculate $$$x = (n+1)*MED — sum(before \space adding \space x)$$$

3) minimize ans

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Notice that after sorting the array, you are left with only two options: either make 'a[n / 2 — 1]' the median or make 'a[n / 2]' the median.

    In the first choice, you need to add 'X' before 'a[n / 2 — 1]' so that it remains smaller than 'a[n / 2 — 1]'. In the second choice, you need to add 'X' after'a[n / 2]' so that it remains bigger than 'a[n / 2]'. Now, let's calculate if this scenario is feasible. Let the sum target be '(n + 1) * a[n / 2 — 1]', denoting it as 't1'. You already have the current sum, which we'll call 's'. Therefore, it's evident that 'X' must be equal to 't1 — s'.

    If '(t1 — s) <= a[n / 2 — 1]', then the answer can be printed.

    However, if '(t1 — s)' turns out to be greater than 'a[n / 2 — 1]', it indicates that the first choice is not viable. In this case, since an answer always exists, the second choice is the correct one: making 'a[n / 2]' the median. Now, calculate the new target sum as '(n + 1) * a[n / 2]', denoting it as 't2'. Then, print 't2 — s' as the answer.

»
3 года назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

There's a clarification that's been sent during the contest for problem M and the statement is not updated. Please note this ahmad_alghadban as the clarification was important to solve the problem.

»
3 года назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Any hints to problem L? thank you.

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится +14 Проголосовать: не нравится

    The edges not used in the m paths, add nothing to your discount so have their weight equal to zero. An edge included in some of the m paths will add a discount equal to the number of paths its included in times its weight, so replace its weight with this value instead. The K vertices will form a subtree, and no matter how this subtree is going to look like, you can cover it with at most K leaves of the original tree. let's say we choose two vertices among the K vertices we need, the best possible for them is to have the maximum path weight (diameter of the tree). Now for the K — 2 vertices left, you try figure it out :)

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve D? Can anyone give me the solution or some hints, please.

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    First notice that the order of the elements is not important as you will sort it anyway, so you can define the subsequence using the frequency of every digit in it.

    From that, you can use dp[i][j], the sum of all cost of strings consisting of the first i digits and the length of the string is j.

    To update that dp you will need another array ways[i][j], which will hold the number of different strings.

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by ahmad_alghadban (previous revision, new revision, compare).

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

really wow lovely contest Thanks all for your efforts.

»
3 года назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

What a great problemset!! I REALLY ENJOYED IT !

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Could anyone give hints about problem C ? Thanks in advance

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    The expected Value $$$e = \frac{\sum p_i}{n!}$$$

    Hint 1 : How can we simplify this expression ?
    Hint 2 : How many times can this pair appear over all permutations p ?
    Hint 3 : What is the final value of e ?
»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can somebody give the answer of A or K thanks!!!

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Could anyone provide some hints on problem N? I thought about storing dfs order in treap so queries of type (2) and (3) would be easy. But how do I know where to insert another node? I think I should either maintain sizes of all the subtrees or "the most right" node in a subtree.

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone give me some hints or solutions for problem L ?

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Remember that three points define an unique circle, and you can find easily some material to find this circle. Try to use a bit of combinatorial to solve the rest of problem.

    Hint: Remember that a O(N^3) solution get accepted in this problem.