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

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

We will hold AtCoder Beginner Contest 135.

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

We are looking forward to your participation!

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

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

LOVE AtCoder's problems! They are always of good quality! :D

UPD: and great difficulty

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

    Another good thing about atcoder is short and to the point problems.

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

How do AtCoder beginner contests compare in difficulty to Div2/Div3?

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

    It's easier than Div3 on problems A and B, but sometimes as difficult as Div3 on problems E and F, the overall difficulty is slightly lower than Div3, personally, I believe it's going to be a interesting contest for people with rating below $$$1450$$$ on CF.

    UPD:I was wrong.

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

    The early problems on Atcoder are much easier than any problems on CF.

    However, in my opinion, the last problem (F) on ABCs is typically substantially harder than the last problem on CF Div3. I think it's harder for me to solve all problems on an ABC (I frequently don't) than all problems on a CF Div3 (I typically do, small sample size though), and since the earlier problems are harder on CF, that implies the later problems are harder on Atcoder.

    In summary, ABCs are definitely easier than CF Div2, but overall harder than a CF Div3 (if you aim to solve all problems). If you're only aiming to do the first few problems, ABCs are easier than CF Div2 and Div3 both (the first problem on last week's ABC was "input X and output 3X^2").

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

      How would you compare ABC's E/F problems to that of CF DIV2 ?

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

        Much easier, though there's been a good amount of variability. I've solved everything on multiple ABCs, but only done that once on a Div2.

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

Where to see the number of people who solved a particular problem during the contest?

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

How to solve F?

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

    Concatenate $$$S$$$ with itself until it has a greater length than $$$S+T$$$. Then, using a string matching algorithm, check which positions in the first $$$S$$$ could be the start of an instance of $$$T$$$. For each of these positions, use the length of $$$T$$$ to figure out which position, modulo the size of $$$S$$$, you'd reach in the concatenated $$$S$$$ after placing a copy of $$$T$$$ starting here.

    Afterwards, the problem reduces to longest paths in a directed graph. Our nodes are the positions in $$$S$$$ and our edges connect each valid position at which we can place a copy of $$$T$$$ to the position at which the next copy of $$$T$$$ would start. If this graph contains a cycle, the answer is $$$-1$$$. Otherwise, we have longest paths in a DAG, which is a relatively standard problem.

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

This is absolutely the most difficult ABC problem I've ever seen...

Do any one know how to solve D? I tried to use a dp but failed.

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

    We have to use the divisibility rule of 13 i.e the difference of alternate chunks of 3-digit numbers from the unit place if divisible by 13 than the number is divisible by 13. so we have the form of (A*100 + B*10 + C)%13 = 5. Here A,B,C consist of sum and difference of ? which can take values from 0-9. Sorry this is what I was thinking during the contest but the idea was too tough to implement.

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

    Submission

    According to the above explanation.

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

    Let $$$dp[i][j]$$$ be the number of length-$$$i$$$ numbers that match the pattern's first $$$i$$$ digits and are $$$j$$$ mod $$$13$$$. Then, we can transition by iterating over every possible digit in the $$$i+1$$$'st position, noting that appending a digit $$$k$$$ to state $$$(i, j)$$$ gives a remainder of $$$10j+k$$$ mod $$$13$$$.

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

    Actually this was a simple digit dp problem. You should explore some problems like that.

    If you think this problem was difficult, then look into this codechef problem. During contest time I implemented it and got it accepted, I had to use 6-7 parameters to define a dp state. And surprisingly the editorial also used same no. of parameters.

    Another example of digit dp problem: Atcoder Educational dp contest, problem S

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

How did you solve F(if solved)?

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

How to solve problem E?

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

I have solve 58 test cases of Problem F out of 73. Than will i get Partial Score or Not. Means at Atcoder there is any concept of partial Score.

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

I think problem E and F are put in a wrong order. I can solve F but can't E.

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

How to solve problem D ?

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

    DP. States are position and remainder.

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

    Go index wise in the string starting from the left end. Think what will be the contribution of the current number formed till now in the modulo 13. DP[i][j] — stores the number of numbers that can be formed using length up to i and have modulo j with 13.

    Obviously, i -> (0..n-1) and j (0..12) Since mod 13 only 12 values are possible.

    Now If at S[i] there is no question mark then the transition is simple. the new number formed is just the previous * 10 + (s[i]), And we have 12 possible previous so check for all of that. Now do % 13 of this and increase the count of the new mod in i. Otherwise, if there is a question mark just do this for all digits from 0 to 9. And update.

    Finally, the answer is dp[n-1][5]

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

Geothermal please save us

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

I want AnandOza or Geothermal to put up an English editorial.

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

    I won't be posting an editorial today--I was working on one after I finished the contest, but I accidentally hit my backspace key just before I finished, causing me to leave the page and lose all of my work. Unfortunately, I don't have time to write it up again.

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

    I didn't participate in the contest this morning, but I'm working on the problems for practice now and might write an editorial (if nobody else has and I actually solve all the problems, haha, but I heard today was a hard round!).

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

Any ideas for E. How to solve it?

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

    Just recursive dp(dp[i][j])

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

      dp[i][j] ?? what dp[i][j] ??

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

        If it is impossible to reach i,j then dp[i][j] will be someting like -1. if not, it will be the minimal number of score needed to reach i,j and the point from witch we went to i,j

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

      This will TLE, as $$$X$$$ and $$$Y$$$ can be up to $$$10^5$$$ and your efficiency is at least $$$O(XY)$$$ (or perhaps $$$O(XYK)$$$, factoring in transitions).

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

Is this game included in rating?

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

500 and 600 problems were more difficult this time than general.

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

Geothermal How to solve problem E?

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

    Just recursive dp(dp[i][j])

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

      Anything?

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

        dp[i][j] is if it is impossible to reach i,j(point with coordinates (i;j) then dp[i][j] will be someting like -1. if not, it will be the minimal number of score needed to reach i,j and the point from witch we went to i,j.

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

Can someone tell me why my F is wrong https://atcoder.jp/contests/abc135/submissions/6580972

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

Will you disqualification a user from the contest if he copy pasted other's code Geothermal? rng_58? chokudai? sigma425? I am asking this because I copyed the code from someone and want to know, will you disqualification me?

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

What is the topic of problem E? It is computational geometry? I would like to know a lot of about this kind of problem.

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

    I solved this with recursive dp: dp[i][j] is if it is impossible to reach i,j(point with coordinates (i;j) then dp[i][j] will be someting like -1. if not, it will be the minimal number of score needed to reach i,j and the point from witch we went to i,j. this may fail in time, so I used rands and probalities and my solution worked with a big chance correct and with a big chance to be fast at test.

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

How to solve C?

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

    I store the total number of monsters in a variable say res.Then I check for each i if B[i]>A[i] then we update A[i+1] with A[i+1]-min(A[i+1],(B[i]-A[i])) because ith hero can defeat some of the (i+1)th position monsters. and for each i we have to update final A[i] value.that is max(0,A[i]-B[i]). Finally we calculate the sum of total number of monsters left say res1. So our answer is (res-res1).

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

      Hi, I know it's been 3 weeks but I've just tried the question today. About the problem, is it a greedy approach? The ith hero attacks the monsters in the ith city as many as possible, then attack the monsters in (i + 1)th city if possible.

      If that's what you meant, then my approach is just the same as you. However, my code got WA on submission. Here's the link: https://atcoder.jp/contests/abc135/submissions/6933616. Can you help me figure out what's wrong? I will try to code as what you stated above as well and see the difference.

      UPD: I figured it out! Integer overflow is gonna trigger me a lot...

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

I have one bad solution for F. (Very slow and naive)
At first, like everyone, concatenate $$$S$$$ with itself until its length greater than $$$|S|+|T|$$$. Then, we want to find the greatest number of copy of $$$T$$$ which is substring of current $$$S$$$. There are many ways to do, but to be more naive, I did binary search and $$$KMP$$$ to find it. How to know if the answer is not $$$-1$$$? There are a lot of better ways to do, but I concatenate $$$S$$$ with itself one more time and did the same thing as previous $$$S$$$.

If the answer is greater than the previous one, then the answer is $$$-1$$$. Otherwise it's our answer.

Time complexity: $$$O((|S|+|T|)log(|S|+|T|))$$$ (with a very big constant)

Not recommend to do this solution. I have to optimize lots of things to make this naive brute force get AC. Submission link:https://atcoder.jp/contests/abc135/submissions/6585502

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

    I also thought of the same idea but did not implement it as I thought it will TLE :|

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

    What is the reason for concatenating s with itself until it's length is greater than |S|+|T|?

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

      If $$$|S|<|T|$$$, it will never contain $$$T$$$ as its substring. When $$$|S|>|T|$$$, it has a chance that concatenating it again can make more copies of T as its substring. So we will concatenate it one more time although its length is now greater than $$$|T|$$$. Of course, concatenating doesn’t reduce the number of copies of $$$T$$$ nor get rid of $$$T$$$ in its substring, but cause bigger constant factor.

      Not related to your question, but I have more optimized submission.(Cutting out log factor) Execution time is not that bad.(65 ms)

      Link: https://atcoder.jp/contests/abc135/submissions/6593400

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

I changed my mind and decided to rewrite and post my solutions. Feel free to check them out at this link!

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

Screenshot-from-2019-07-27-17-32-21-Latest
Why are Atcoder servers so slow at the start of the contest ? The tasks doesn't load for me for the start of 2 — 3 minutes of contest :((. Am I only one facing such situation or anybody else too ?

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

Can somebody give me the data of problem F? I debug for so long but WA four tests

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

    I also want the data of problem F. I got WA on seven tests and I don't know what my mistake is.

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

Only Kotlin 1.0.0 supported? Sheesh, that's tough to work with; all the deprecations and missing features...

Though I guess the veterans here would tell me to use a "real" language like ^C(\+\+)?$ or Rust...

edit: fixed the regex

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

Could you help me solve F using z-function, I did it but it didn't pass all of test cases (only 58 test cases were passed), I guess the issue relating to handling the result -1. My submission. Thank you!