chokudai's blog

By chokudai, history, 2 weeks ago, In English,

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!

 
 
 
 
  • Vote: I like it
  • +35
  • Vote: I do not like it

»
2 weeks ago, # |
  Vote: I like it +11 Vote: I do not like it

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

  • »
    »
    2 weeks ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Although they do not have English editorials officially ( yet!, hopefully they will in the future ), but Geothermal usually writes his solutions in English, and posts them shortly after the contest. So you should read them, it is very helpful.

  • »
    »
    2 weeks ago, # ^ |
    Rev. 2   Vote: I like it +3 Vote: I do not like it

    There will be a blog after the contest by Geothermal sharing his/her approach in English.

»
2 weeks ago, # |
  Vote: I like it +19 Vote: I do not like it

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

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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
»
2 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

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

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    2 weeks ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it
    Hint
    Solution
    • »
      »
      »
      2 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Thank you very much. I got it now :))

    • »
      »
      »
      2 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

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

      • »
        »
        »
        »
        2 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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$$$.

  • »
    »
    2 weeks ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    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.)

    • »
      »
      »
      2 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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 ?

      • »
        »
        »
        »
        2 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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?

        • »
          »
          »
          »
          »
          2 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          This comment made all the difference to me. Thank you for your Time and effort. I now got it perfectly. :))

»
2 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    2 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

    • »
      »
      »
      2 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Thanks my saver!!! I feel so dumb! Sure I didn't realised it, I thought the entire solution was wrong, while instead I did a so crazy error... Replaced the out string with a stack, printing directly in the right order, and everything worked. Unfortunately too late for the contest. Next time... :) thanks again