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

Привет, Codeforces!

В Dec/15/2018 17:35 (Moscow time) состоится Educational Codeforces Round 56 (Rated for Div. 2).

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

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

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

Задачи вместе со мной придумывали и готовили Роман Roms Глазов, Адилбек adedalic Далабаев, Владимир vovuh Петров и Иван BledDest Андросов.

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

А вот сообщение от наших друзей из Harbour.Space:

Hello Codeforces!

We are excited to announce that the Hello Muscat Programming Bootcamp registration is open! The camp will take place from March 9th to March 15th, 2019, and our early bird discount of 15% is going until December 15th!

This next edition in our Hello Programming Bootcamp will run in parallel with the traditional Moscow ICPC Workshop — both Bootcamps’ contests will be identical, and contestants will be able to see their position in the General Leaderboard. Every day, both camps will be competing simultaneously, 4,000 kilometers from each other!

REGISTER FOR THE BOOTCAMP

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

Место Участник Задач решено Штраф
1 waynetuinfor 7 190
2 nuip 7 226
3 ToTLeS 7 246
4 danya.smelskiy 7 252
5 998batrr 7 272

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

Место Участник Число взломов
1 9646516 75:-20
2 interestingLSY 49:-24
3 niki4smirn 12:-1
4 katana_handler 11
5 marismmm 8
Было сделано 298 успешных и 565 неудачных взломов.

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

Задача Участник Штраф
A sorry_stefdasca_snsdsux 0:01
B KerimKochekov 0:02
C Golovanov399 0:05
D Golovanov399 0:09
E ko_osaga 0:25
F vintage_Vlad_Makeev 0:28
G tfg 0:09

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

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

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

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

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

Clashes with COCI #3

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

Yes, it is rated for Div. 2

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

Is D bipartite checking?

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

how to solve D ?

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

    If graph contain odd cycle, answer is zero as no valid assignment can exist.

    Otherwise, let us find 2-coloring of each connected component in graph. Say, x nodes are colored red while y nodes are colored black. There are exactly pow(2,x)+pow(2,y) ways to color this component. Take product of this for all components.

    Reason of pow(2,x)+pow(2,y). You need sum of edges to be odd. So, one of the value on edge is 2 and other value is either 1 or 3. pow(2,x) assume we assign all red colored nodes with either 1 or 3, giving pow(2,x) choices. Same for y.

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

    It can be easily solved with BFS. And I came up with it a long time later, but I couldn't solve it because of Memory Limit Exceed.

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

It took me 4 wrong tries to actually realize that author has not mentioned that Graph will be connected in Problem D :'(

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

For those wondering about high submissions for G, You might find this problem interesting :)
MDIST

Can anyone share their idea for E and F?

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

I got a couple of wrong answers on D because I had mod = 1e9+7 saved in my template and forgot to change it to 998244353, and when I finally realized the mistake I corrected it in the last 10 mins. For those who say what's the use of setting mod to such a weird value its for people like me :-p

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

How to solve C? I made a great effort to solve it by using greedy algorithm only to get a wrong answer on #9.

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

    Yours approach looks correct.

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

    It's how you approached it.

    I did like this: split array a into halves, start filling from the middle of a (i.e. from right to left of array b).
    Denote the element b[n / 2] as x, the two middle elements of a will be x div 2 and x - x div 2 respectively.
    For the next elements, let's denote the ones we need to fill in the left half and the right half as L and R respectively. Also, we have MinL as the minimum of filled numbers in the left half, MaxR as the maximum of filled numbers in the right.
    Obviously L ≤ MinL and MaxR ≤ R. From there, you can easily split the element from b into two most optimal halves that satisfies both inequalities above.

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

    I did the same mistake :( So, now I have made a macro with int as long long.

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

I liked D. So, for any edge (u, v) exactly one of the nodes will have value 2.

If the graph has odd length cycle, then its impossible. Otherwise, simply do a black-white coloring of the graph. Now let # of black nodes be B.

Then in one case you can write 2 in B nodes, and the rest N-B nodes will have 2 options (1,3). In second case you can write 2 in N-B nodes, and the rest B nodes will have 2 options (1,3).

Ans = 2^B + 2^(N-B)

Code: https://ideone.com/2YmsN5

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

Are there faster solutions than Nlog^2N in E and Q*(2^K)*logN in G? Got TLE on both.

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

Problem D is pretty good ^^

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

For E, I couldn't pass a segtree of ordered_set in 6s. Is there any other better solution? Or it was just intended that we use BIT instead of segtree.

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

Am i wrong or O(m * log^2) solution should get TL.

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

Problem D: when m==0 why the hell ans = 3^n ?? (-_-)

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

has anyone done E with Bitset ? I got TLE at testcase 13

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

What will be the Rating of problem D?

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

Why did this get TLE?

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

Check my submissions if you are looking for challenging hacks. You have to complete 4 funny tasks. Good luck :)

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

I had the same sqrt(N) blocks idea for E but ended up with memory limit exceeded. Did I derp too hard or was there something I'm missing? I had a 450 x 200005 int matrix at most

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

What's the hack for problem D?

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

My accepted solution for problem E in O(n * m) time works 5225 ms.

Can anybody hack it? Maybe halyavin?

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

Can anyone tell me, why i am getting compilation timeout???submission

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

Solution for F?

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

halyavin is coming!!!

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

halyavin is coming!!!

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

I've just started using CodeForces and this was my first contest (and I got 2 accepted solutions). Can someone tell me:

why I still dont have a rating ? Will my profile be updated later (after few hours) ?

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

47050528 hey, this is the fisrt time i am competing. Can anyone explain me whats wrong with this code for first problem.

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

Can anyone please tell what is wrong in this solution for the problem D code

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

Can anyone explain the solution for problem C? I can't understand why we r taking a max of b[i] and b-a[n-i].

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

Can someone please point out why do I hit a time-limit-exceeded on test 2 with this submission?

https://mirror.codeforces.com/contest/1093/submission/47082541

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

    Graph doesn't have to be connected. Here is example: n = 3 * 10^5, m = 0 Then this part:

    Spoiler

    will take n^2 time. Another bug in your code is in this line:

    ans += (1 << red) % MOD + (1 << black) % MOD;
    

    black and red can be bigger than 64. Better option is to just count every 2^k % MOD at the start of your program:

    POT[0] = 1;
    for (int i = 1; i < N; i++)
        POT[i] = (POT[i - 1] * 2) % mod;
    
»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve E?

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

    My way to solve this problem (not very efficient, but it passed):

    Represent each number as a point , then the problem will become count the number of points in the rectangle with two opposite vertices (la, lb) and (ra, rb). You can easily solve this problem with compressed 2D BIT.

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

Can anyone explain solution to E with ordered statistics set? I saw few codes that get AC but I don't understand them all. And what does this magic loop:

for(int i = x; i <= n; i += i & -i)
»
7 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Can anyone figure out why my program will get many negative outputs in problem D? 47086094

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

i missed this -_________-

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

anyone solved D with DP ??

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

Will there be an editorial?

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

Will there be an editorial?

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

Can anyone help me with my code for D. I'm getting TLE for test13 My Submission

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

where is the editorial??

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

The idea behind E's solution is good. You have to choose such a block size such that n*(block_size+log(n)*n/block_size) is minimised. It is not necessary that optimal block_size is root(n),

PS: E passes with block_size = 3000.

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

I am pretty sure that problem F is the exact same problem as 204D - Little Elephant and Retro Strings. but instead of using only 2 values he uses k.

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

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

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

Can anyone tell me what am I doing wrong in part D.

link : https://mirror.codeforces.com/contest/1093/submission/47249694