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

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

1221A - Игра 2048

Идея: Roms

Разбор
Решение (Roms)

1221B - Кони

Идея: BledDest

Разбор
Решение (PikMike)

1221C - Идеальная команда

Идея: Roms

Разбор
Решение 1 (BledDest)
Решение 2 (PikMike)

1221D - Сделаем забор великим снова

Идея: Roms

Разбор
Решение (Roms)

1221E - Игра со строкой

Идея: Roms

Разбор
Решение (Roms)

1221F - Выбери квадрат

Идея: Neon

Разбор
Решение (Ne0n25)

1221G - Граф и числа

Идея: BledDest

Разбор
Решение (BledDest)
  • Проголосовать: нравится
  • +63
  • Проголосовать: не нравится

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

Very sorry gor noob question, but in G why is F(0.1) number of independent sets in graph?

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

    $$$F(\{0, 1\})$$$ is such a coloring that no pair of vertices colored $$$1$$$ are connected by an edge. So the subtask is to count the number of ways to choose vertices to color them $$$1$$$ in such a way that no pair is connected by an edge. And that's the definition of an independent set.

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

      Yeah, I figured it out by myself after some time... I think you should include this explanation in the editorial though, it's not immediately obvious.

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

        Meh, I think it's fine. Editorials are not supposed to be immediately obvious for everybody.

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

I still don't understand Why it is not beneficial to increase the length of some board by three or more.... (Problem D) Can anyone help???

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

    because there is no need. even if u increase by 2 or 1 or 0 u can de different from ur neighbors

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

    Assuming $$$a_i = a_{i-1}$$$. We can increase $$$a_i$$$ or $$$a_{i-1}$$$ by 1.
    If we decide to increase $$$a_i$$$ by 1, it doesn't change anything before, so the Fence is still great up to now.
    If we decide to increase $$$a_{i-1}$$$ by 1, it can equal to $$$a_{i-2}$$$ and break the Fence's greatness. In this situation, we can continuously increase $$$a_{i-1}$$$ by 1 (now, it increased 2 units) or increase $$$a_{i-2}$$$ by 1.
    That's the reason why we should increase every $$$a_i$$$ at most $$$2$$$.

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

      what if increasing ai-2 by 1, ai-3 becomes equal to ai-2

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

    3 case structure theorem

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

can someone explain 5th question . I dont think explanation is correct , how can u convert fourth type segment into 2nd type segment and what about the cases in a>=2*b

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

Can someone give me the proof for problem B?

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

Hold on, what is OR-convolution mentioned in G? I couldn't google it.

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

In problem A , how to prove that if sum of numbers other than numbers greater than 2048 is greater or equal to 2048 then answer will be Yes ?

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

Very weak test cases for A even my wrong code got accepted

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

can someone tell me what if (c + m + x - 2 * mid >= mid) means in problem C ?

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

    If $$$mid$$$ teams are formed, then $$$mid$$$ coders are already taken and $$$mid$$$ mathematicians are also taken. That leaves us with $$$(c - mid) + (m - mid) + x$$$ people to fill the empty spot in each of the $$$mid$$$ teams. So if that condition if true, then there are enough people to form at least $$$mid$$$ teams.

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

In Problem E, when we consider segments of type 4, where len >= 2*b, how can we say that Bob can always convert it into a segment of type 2? If (a+b) <= len < 3b, if Bob makes his move, the segment will become type 3

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

    When $$$len \geq 2*b$$$, Bob can always get a segment of type $$$2$$$ by saving the $$$b$$$ right most places and then choosing his segment. Eg. if $$$b=2$$$ and $$$len=8$$$, $$$\ ........ \rightarrow\ ....XX..\ $$$ Now he can use the right most place when Alice doesn't have a move left.

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

Problem F ,if I submit my code with GNU C++17 ,I would Wrong answer on test 2, if I submit my code with GNU C++14,it was Accepted.Could someone tell me why? my code: 60964098 60962460. Sorry for my poor English.

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

In 5, how are we sure that 2b>=a when it is only mentioned that a>b?

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

need a proof for problem "A" solution please

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

There are accepted solutions (e.g. 60854023)
for Problem C (Perfect Teams) which are just
$$$min \{c, m, \left \lfloor{\frac{c+m+x}{3}}\right \rfloor\}$$$

Could someone please prove (or explain the idea behind) the formula?

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

    By definition, each team consists of a coder, a mathematician, and exactly three people. The resource with minimal availability decides how many perfect teams you can build.

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

      i can understand how minimal availability of c & m decide the outcome but what does (c+m+x)/3 here signify?

      can you please explain? _/\_

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

haizz i am bad at implementation algorithm. That's why i rarely do well in the contest :< . Can someone give me advice on this matter, pls !! sorry for my poor english :D

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

    Read and understand good codes of the questions you are doing... try to remember loopholes and learn to make your code short and simple. Also each line of the code should be important that is your code shouldn't be redundant.

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

Can E be solved like this? I am not sure! :3

First take segment length of dots, then sort them and obviously ignore the lengths smaller than b. Then we declare vector < pair > info which saves what happens if alice starts, if bob starts when there are first i lengths only.

Now in these sorted lengths, take the first one and save who wins if there is only that first segment and alice starts the move, if there is only that last segment and bob starts the move

Then we iterate i from 1 to size of segment lengths array. For i-th element, we decide who will win if alice starts, if bob starts the move when there are only first i segments. We decide considering the i-th length and the information from info[i-1]......and save it in info[i]......

**sorry for my explanation.....i suck at explaining :(

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

problem A mathematical induction proof: (1) if the sum of the not larger than 1 elements is greater than 1, the numbers can merged into 1. obvious. (2)suppose the sum of not larger than 2^(k-1) elements is greater than 2^(k-1), the numbers can be merged into 2^k. Then if the sum smaller than 2^k elements of is larger than 2^k , the numbers can be merged into 2^k.

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

in D what is the proof that time complexity of the recursion won't be large I did not get how the dp is exactly working

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

    because all boards will be increased by no more than two.

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

      Yeah I know but there's a for loop with calc function with three possibilities x=0 x=1 x=2 so it's o(3^n) complexity isnt it ? Or if statement is making it o(n) but why

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

My recursive DP solution for problem D is timing out , It times out in the test case where answer is always 0 , the weird thing is that it times out even after I hardcode the case where number of elements are always 1! can someone please check and let me know where I can optimize ? Thanks ! https://codeforces.com/contest/1221/submission/61071469

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

    I hope your problem is already solved by now, but I'm writing it for other people!

    Use fastio. I was having the same problem! Write this inside main(): ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

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

    Great Code!!!

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

Can anyone please help me in problem D. I am getting wrong answer on teset case 2. I am using tabulation approach instead of memoization. Here is also Link to my submission. Thanks in advance

#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long int ll;
int main(){
    SPEED;
    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll a[n];
        ll b[n];
        for(ll i = 0; i< n; i++){
            cin>>a[i]>>b[i];
        }
        ll dp[3][n];
        dp[0][0]=0;
        dp[1][0]=b[0];
        dp[2][0]=b[0]*1ll*2;
        for(ll i = 1; i <= n-1; i++){
            for(ll j = 0; j< 3; j++){
                ll temp = LONG_MAX;
                for(ll k = 0; k < 3; k++){
                    if(a[i]+j!=a[i-1]+k){
                        temp = min(temp, dp[k][i-1]+b[i]*1ll*j);
                    }
                }
                dp[j][i]=temp;
            }
        }
        cout<<min(dp[0][n-1], min(dp[1][n-1], dp[2][n-1]))<<endl;
    }
}
»
5 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

I don't understand the formula of DIV2C c + m + x — 2 * mid >= mid__ Please help...

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

Why am I getting a TLE in this solution to the D. Link: https://codeforces.com/contest/1221/submission/61306295

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

I can't understand editorial for problem F. What do you store in the segment tree, also how do you initialize it?

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

In problem E if 2b<a then the class number 3 is mathematically incorrect. maybe use a+b instead of 2b?

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

Can anyone tell me the botton up solution of question D? Link is ->
Question D

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

Bottom UP dp solution for C (make that fence great Again): link https://codeforces.com/contest/1221/submission/76082735

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

can we solve E using grundy numbers?

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

    I guess no since grundy theorem requires a symmetric game and now a isn't equal to b.

    Maybe there is a generalization of the theorem but idk.

»
12 месяцев назад, # |
Rev. 6   Проголосовать: нравится 0 Проголосовать: не нравится

Deleted

»
9 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Can someone please explain why is this code for problem D getting TLE'd? Thanks in advance. https://codeforces.com/contest/1221/submission/216444244