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

Автор chokudai, история, 5 лет назад, По-английски

We will hold AtCoder Beginner Contest 146.

The point values will be 100-200-300-400-500-600.

We are looking forward to your participation!

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

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

It would be better if someone post English editorial of AtCoder contests!

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

I've written an English editorial: https://codeforces.net/blog/entry/71701

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

For problem C Can someone tell me what is wrong in my code I got WA in one test case

Your code here...import math
n,m,x = map(int,input().split())
#print(n,m,x)
for i in range(1,25):
    k = (x - m*i)//n    
    #print(k,i)
    if k<0:
        print((x-m*(i-1))//n)
        break
    if k==0:
        print(k)
        break
    if int(math.log10(k))+1 == i:
        print(min(10**9,k))
        break
»
5 лет назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

Anybody else found this contest somewhat easier than a normal beginner contest?

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

can Somebody please explain to me more Problem E ? I have read both of the tutorials and still don't get it. Thank you

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

      I have a question for the last line of the hint. Shouldn't it be F(j) = F(i) mod K?

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

        Ah yes. I was calculating everything modulo $$$K$$$. I forgot to explicitly write it.

        Actually, the main jist is that, you have to do all calculations modulo $$$K$$$, the only inference was that you should only consider subarrays ( or contiguous subsequences, as questions states ), of length at most $$$K-1$$$.

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

    You should explain what you do understand and don't understand, and/or what step in someone's editorial you can't follow.

    (Otherwise there's nothing stopping someone else from posting yet another explanation that you don't understand, which isn't helpful to them or you.)

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

      Thanks for the reply. I am not saying you haven't explained well. I just coudn't understand and I know it's my fault cause apparently it's too easy for many people. I get the part where there has to be Pi≡Pj but what I don't get is how to get all the pairs verifying this condition ?? and about the condition you montionned do you mean that the maximum number of elements should be less than K ?

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

        Thanks for explaining what steps you wanted to know more about!

        Let me try to explain those parts. Let's solve the reduced problem: given an array $$$p$$$, find all pairs of equal elements that are at most $$$K$$$ apart. To do that, let's count all the pairs $$$(i, j)$$$ (with $$$i<j$$$ and $$$p_i=p_j$$$) for a given $$$j$$$. Given a fixed value of $$$j$$$, we count the number of indices $$$i > j - K$$$ such that $$$p_i = p_j$$$ (which we can do efficiently using a hashmap to keep track of the counts for each $$$p_i$$$ in the past $$$K$$$ indices). If we add up all these numbers (loop over each $$$j$$$), we end up with the total number of pairs. This is because every pair $$$(i, j)$$$ is counted exactly once, when we count all the valid $$$i$$$s for that $$$j$$$.

        Does that help?

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

Hi all, for problem F, I did a (too simple) implementation. It obviously fail, but the problem is that I am not able to understand why it should return a shortest path that is not the lexicographically minimal. This is my code:

ll solve()
{
    int N, M;

    cin >> N >> M;

    string s;
    cin >> s;

    int counterOnes = 0;

    // here I just filter if there is no solution
    for (int i = 0; i < s.length(); ++i)
    {
        if (s[i] == '1')
        {
            ++counterOnes;
            if (counterOnes >= M)
            {
                cout << -1 << endl;
                return 0;
            }
        }
        else
        {
            counterOnes = 0;
        }
    }

    string out;
    int index = s.length() - 1;

    // if I reach this, there is a solution for sure
    while (index > 0)
    {
        // loop from the biggest step to 1
        for (int j = std::max(0, index - M); j < index; ++j)
        {
            if (s[j] == '1') continue;

            out += to_string(index - j);
            out += " ";
            index = j;
            break;
        }
    }

    out.pop_back();
    std::reverse(out.begin(), out.end());
    cout << out << endl;

    return 0;
}

I cannot identify a negative pattern to proof that this fails :( Is there a way to download/see the testcases, after the ATCoder contest terminates?

Thanks a lot for any help

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

    std::reverse(out.begin(), out.end()); You actually reverses the "string", not the numbers. For example, "1 12" becomes "21 1" from your code, but it should be "12 1". Then the rest of your solution is correct.