Автор awoo, история, 8 лет назад, По-русски

Привет, Codeforces!

В 05.03.2019 18:05 (Московское время) состоится Educational Codeforces Round 61 (рейтинговый для Див. 2).

Продолжается серия образовательных раундов в рамках инициативы Harbour.Space University! Подробности о сотрудничестве Harbour.Space University и Codeforces можно прочитать в посте.

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Вам будет предложено 7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Задачи вместе со мной придумывали и готовили Роман Roms Глазов, Адилбек adedalic Далабаев, Владимир vovuh Петров, Иван BledDest Андросов и Максим Neon Мещеряков. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

Удачи в раунде! Успешных решений!

Поздравляем победителей:

Место Участник Задач решено Штраф
1 vintage_Vlad_Makeev 7 321
2 kmjp 7 380
3 AntiBsayer 7 452
4 neal 7 721
5 I_love_Tanya_Romanova 6 204

Поздравляем лучших взломщиков:

Место Участник Число взломов
1 algmyr 121
2 MarcosK 119:-6
3 Mohammad.H915 60:-1
4 Bakry 50
5 AhmedMaherAli 45:-1
Было сделано 1837 успешных и 1117 неудачных взломов.

И, наконец, поздравляем людей, отправивших первое полное решение по задаче:

Задача Участник Штраф
A vintage_Vlad_Makeev 0:01
B 1021869 0:03
C vintage_Vlad_Makeev 0:08
D vintage_Vlad_Makeev 0:24
E TripleM5da 0:20
F _Ash__ 0:06
G road_to_9k_mmr 0:25

UPD: Разбор опубликован

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

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

Wish interesting tasks!

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

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

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

hope not being like Div.1 ;)

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

omfg i cant waitr

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

i guess most of cf users are poor

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

Hope test cases will be stronger than previous. Good luck Happy coding

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

I hope the contest is not declared unrated this time and no technical issues or unethical behaviour from the community members.

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

I want high rating.

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

awoo, простите! Не "Мизаянову", а "Мирзаянову"

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

Wish you happy coding =)

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

I want easy tasks so I can get high rating!

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

I always hate delays But could you please start contest later? We have just left school (Also i know that i am not an important person but i think for most Iranian person this time is really bad)

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

This is my first contest

I hope I become green!

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

Deleted

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

Please suggest some problems like C today for practice

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

Why my code got Runtime error on test 1 on problem C, while same code works fine locally and ideone

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

How to solve F?

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

How to not get MLE on G?

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

Was D binary search + simulation?

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

How to approach problem E? It seemed more like math/greedy than anything else, but I couldn't come close to a solution.

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

    Well, model solution does something like that:

    Let L be the least common multiple of all numbers from 1 to 8 (L = 840). Then, if in the optimal answer we need to use c items of weight i, we may write c in the following form: , where . Then we may merge items of weight i into p items of weight L, if we fix q.

    This allows us to use the following dynamic programming solution: dp[x][y] — the maximum number of items of weight L we may obtain, if we tried x first types of items, and got total weight of y while using less than items of each type. Note that the second dimension should have size 8L, since it is the maximum possible sum we may obtain in this case.

    But it seems that some participants used different heuristics and random. We aren't actually sure if such solutions should fail.

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

    You could solve it my noticing that if the total sum is bigger or equal than W, the answer must be between W-8 and W. So I approached the total sum to between W and W+8 greedly removing the itens and then I checked if I could remove the difference between the actual sum and the answer, this could be done using smaller knapsacks as the difference would be no more than 16.

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

Just the problem was searching range. I was in a fear as hell. Codeforces should check their algorithm time complexity, not just tight range.

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

Is O(n * logn * log(2e12)) expected soln of D??
How to solve F??

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

I think D deserved just a little higher time limit. My O(log(1e12)*(k*log(n)) soulution didn't pass, I tried to optimize best as I could.

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

why n(log^2(n)) gives TLE in D ?

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

What was testcase #5 in C?

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

So shitty D

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

Problem C ?? Approach to solve problem like this ??

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

    Here is possible to use partial sums approach. Also, you can use the event-based approach.

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

    Given an array of numbers, partial sums is a technique used to get in O(1) the sum of numbers in an interval [l, r]. It works by iterating from zero to the length of the array adding up for every position the sum of the previous position. So if your partial sums array is called sum you can get the sum between [l, r] by doing sum[r]-sum[l-1]. Precalculate the partial sums array will take you O(n), where n is the length of the array.

    In this case you can do the partial sums array such that sum[i] = k if there are k workers to paint the i-th fence. To make the partial sums without iterating from l to r every time, you can simply add 1 to sum[l] and -1 to sum[r-1] because you know in that positions someone will start painting and had finished painting respectively. Finally you make the sums, such that sum[i] += sum[i-1].

    Now you can make partial sums again but counting the number of fences to be painted by zero, one and two painters respectively, to easily know for each interval [l, r] how many fences will not get painted if the corresponding painters covering that interval are not hired.

    Note that this technique is useful for problems that does not have updates over the values of the array. If you find a problem where you can do partial sums and your algorithm does not pass in time because the update queries, try something like Fenwick Tree or Segment Tree.

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

Number of people who solved D are too misleading, I read it very late (It's my fault).

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

For problem D: Beginning of 4th second both laptop has [1,1] charge but there was still one minute to finish. How does the answer be 5?

I just missed this got wrong answer at 12 :(

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

How to solve C if constraints were 10^5 ?

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

Easier B than A is now regular event. We should try solving B first from next contest.

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

Really nice C ..haven't seen such a C in a while

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

Can someone explain C a bit please? It seemed like a really neat problem, but sadly haven't seen anything similar before.

P.S. That problem A was so wrong for so many reasons...

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

Why is this dp(problem F) wrong?

  • dp[i][j] is the answer for the substring s[i..j]

  • For every string s, let the last character I'll delete (in the optimal way to delete all of the string s) be C. Since that will be the last character, the answer will be 1 + the sum of independant answers for the substrings that you'll get once you delete every occurence of C in s. So I go through all possible characters from 'a' to 'z' and sum up the answer for every substring between two occurences of C in s, then add 1.

It's exactly like going backwards in the optimal process of deleting equal substrings.

I realise it's not the same dp as most solutions, but I believe the logic is correct..

Submission.

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

Yall got any idea why this 50850982 gets WA?

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

D passes with priority queue, exceeds limit with sets.Good question overall

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

When you know your accepted solution is wrong so you hack yourself

Edit: See Hack

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

Many tasks can be found on informatics.msk.ru

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

Can someone please explain this solution?

https://codeforces.me/contest/1132/submission/50833595 (Author: PrakharJain)

It's a simple and nice solution, but I fail to understand how it works.

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

    For a particular subarray [i, j], I'm just iterating through all possible positions k which would form the last position of the segment which would be deleted together. The character at k should be same as in i, of course. And, then in the transition we can stop considering one of the positions (either i or k as they are deleted together). So, both the transitions: ans = Math.min(ans, recurse(i, k — 1) + recurse(k + 1, j)); or, ans = Math.min(ans, recurse(i + 1, k) + recurse(k + 1, j)); should work.

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

In problem A test case: 0 1 1 0 should print 1 because i can do just like that "() ()" I've been hacked because of that

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

How to solve C for n, m = 106?

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

Can C be solved in linear time?

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

if i hack a solution after the contest in educational round do i get points or not ?! thx in advance :)

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

Please Help : Any way to remove TLE in F using map

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

How to solve G??

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

    first for each index i find the maximum index j such that j < i and aj is greater than or equal to ai,call this last[i]. this can be done in linear time using a stack.

    consider ans[i] as the answer if we start our sequence from position i.now make a maximum segment tree on ans values and iterate i from 1 to n there are two cases :

    1. i > k : in this case remove the value from position i — k and add 1 to positions in range [max(last[i] + 1,i — k + 1),i] , now the answer for query ending in position i is maximum value on our segment tree

    2. i <= k : in this case you just have to add 1 to positions in range [last[i] + 1,i]

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

omfg bad pretests.........

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

Has anyone solved C using DP?

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

Just as of now I realized how atrocious pretests of problem C were. My solution got like, 4 critical flaws right within.
And none of them got caught during contest time. I fixed one by one and got WA one by one at tests that are obviously not pretests.
Having a closer look, such tests are not really too complicated (yeah, I would blame myself as well for not testing properly and got hacked/WAs, but it's irrelevant here), making the issues going way worse.
Really wish Educational Rounds never got such incidents ever again.

P/s: For a brief overview, I calculated the number of cells being painted once/twice obviously wrong and still ACed before hacking phase lol.

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

why my submit be hacked?

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

How to solve problem E?

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

Oof my A got hacked, of all things. There goes my rating...

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

Why have the ratings not changed yet?

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

Getting older waiting for the system test o_o

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

Сдал 3 таски — прошла 1 :(

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

Why the rating didn't change?

Is it unrated?

Or The system testing didn't finish?

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

I wonder why this solution gives a TLE on test case 9 in problem — C (https://codeforces.me/contest/1132/submission/50857265). I went through other solutions and they were more or less same as mine (2 cumulative arrays).

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

Can someone please comment more on this solution http://www.usaco.org/current/data/sol_lifeguards_platinum_jan18.html for problem C?

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

please publish editorial with neat codes.

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

When is the tutorial going to be published?

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

Pretests for C should have been stronger

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

with this contest I finally became blue! it took a long time what eventually I made it :))) If you are also struggling to go Cyan -> Blue, keep it up because it is worth it!

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

Editorial please.

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

waiting for editorial

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

When you screw up the competition and get demoted to blue, but out of pure spite you want to bring everyone else with you. spite

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

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

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

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

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

Third question(C) is little bit more tricky from last div2"s third question.

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

I dont like the way how announcement of prob.C works. When I read "**so you decided to hire q painters to paint it**", in my mind had a confusion, if q painters would paint all the sections or not, but then I answered this for myself that "**q painters to paint it**" meaned all sections would be painted if q painters all worked. Because I joined virtual contest, so I got wa, and the question came back again with another answer: may be not all of sections would be painted, and I tried again and got ac. For now, I still wonder, if someone want to paint their fence, they must make sure that all their fence is painted, or maybe Im just a stupid man try to talk bullshit without anyone's care. Plz tell me your opinions, thanks alot.

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

RIP. I should do all possible cases for Binary search of Binary search

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

I am very interested in how the top hackers find our wrong solution and hack us(Just interested, I know why i was hacked).

-- I solved BCF and my A was hacked and I have the same score as others who solved ABC QAQ