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

Автор atcoder_official, история, 8 месяцев назад, По-английски

We will hold Japan Registry Services (JPRS) Programming Contest 2023 (AtCoder Beginner Contest 324).

We are looking forward to your participation!

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

»
8 месяцев назад, # |
  Проголосовать: нравится -76 Проголосовать: не нравится

is it rated?

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

Why the rating changes in recent round rolled back?

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

    For at least 3 of the last ABC rounds standings were updated and rating changes recalculated, but I haven't seen any announcement regarding this matter.

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

atcoder beginner contest is like div 3 contest of codeforces and is very good for beginners everyone should participate.

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

Solve in A-B-C-E-D,although I may be not able to solve e.

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

    So, what things should I say?

    Today's contest is even easier than the previous one!

    I only took 23 munites to flash through problem A, B, C, D!

    Upd in 2023.10.14. 21:15 CST: Today is my first time solving the problem A, B, C, D and E all! Water!

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

I might be wrong, but I vaguely remember solving F on Leetcode long ago.

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

can F be solved using Dijkstra's algorithm?

My submission

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

Does anyone have any hints for problem F? I can't even solve the easier version where $$$c_i = 1$$$ for all $$$i$$$.

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

For problem D could anyone tell what's that only wrong answer : submission

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

A-F easy to think and code but agonizing to debug for me, got so much penalty :(

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

    Can you tell my why this approach is wrong for F. https://atcoder.jp/contests/abc324/submissions/46583832

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

      To begin with, the assumption that if we maximise values of path from 1 to i, and extend them to get a path with maximum value for 1 to n, is wrong.

      Test case
»
8 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Why do we need to binary search the answer in F and why just a single depth-first pass doesn't work? I tried keeping the best possible pairs of values of numerators and denominators for each node, then calculating the best possible dp values for each node as well, but I got WA in 14 testcases. This approach does feel hacky, but I don't immediately see a reason why it doesn't work.

  • »
    »
    8 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится
    Test case
    • »
      »
      »
      8 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      For this test case I'm actually getting 0.107930595039702, which I believe is supposed to be $$$\dfrac{1101}{10201}$$$.

      Here's the code:

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

        That case was created for soln, which calculates 1 to i paths.

        Since you are calculating i to n paths, switching the vertex on the same case fails it.

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

Actually A-F (maybe even G) was easy to think, but the implementation...

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

Problem B has weak testcases

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

qp

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

solved G in 9min after the contest :(

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

My solution for G is different from the editorial, so I will share here.

Each sequence $$$S_i$$$ can be represented with two intervals. $$$[L_i, R_i]$$$, which is the corresponding index interval on the original permutation, let's call it index interval. And also $$$[LV_i, RV_i]$$$, meaning that the numbers on the sequence $$$S_i$$$ can only be in that interval, let's call it value interval. Initially for $$$S_0$$$, we have $$$[1, n]$$$ for both index and value interval. If we correctly compute these two intervals for each sequence, we can use a persistent segment tree to recover the size of the sequence. This segment tree will have $$$N + 1$$$ versions. Each version corresponds to a prefix of the given permutation. The i-th position on the v-th version will indicate whether or not the number $$$i$$$ is present on the permutation's prefix of size $$$v$$$ (we will have either $$$0$$$ or $$$1$$$ in each position). My submission.

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

I tried to solve question c but it is failing in some cases. Here is my submission. can someone tell me why my code is failing like some testcases

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

    Try the testcase,

    N = 2

    T' = aaaa

    S = [aaa, aaaaa]

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

      Thank You!!!

      It helped me in debugging my submission too.

      Any tips on how to not miss such corner cases when implementing solutions during contest?

  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится
    • Line 98 is correct: if(diff<=1)ans.pb(i);
    • Line 112 is not correct: if(diff==1)ans.pb(i);

    They should both be using <=.

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

By the way the video editorial of this contest is very cute lol

Some snapshot

»
8 месяцев назад, # |
  Проголосовать: нравится -18 Проголосовать: не нравится

Can someone tell me why my code is failing like some testcases in Problem C

a,b = input().split() ans = [] for i in range(int(a)): c = input() if b==c: ans.append(i+1) elif len(b)==len(c): temp = 0 for j in range(len(b)): if b[j]!=c[j]: temp+=1 if temp>1: break if temp==1: ans.append(i+1) elif len(b)+1 == len(c): temp = -1 temp1 = -1 for j in range(len(b)): if b[j]==c[j]: continue else: temp = j break if temp!=-1: for j in range(temp+1,len(b)): if b[j-1]!=c[j]: temp1 = 0 break if temp1==-1 or temp == -1: ans.append(i+1) elif len(c)+1 == len(b): temp = -1 temp1 = -1 for j in range(len(c)): if b[j]==c[j]: continue else: temp = j break if temp!=-1: for j in range(temp+1,len(c)): if b[j]!=c[j-1]: temp1 = 0 break if temp1==-1 or temp == -1: ans.append(i+1) print(len(ans)) print(*ans)

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

    Want a more diverse presentation? Using markdown

    • »
      »
      »
      7 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится
      a,b = input().split() ans = [] for i in range(int(a)): c = input() if b==c: ans.append(i+1) elif len(b)==len(c): temp = 0 for j in range(len(b)): if b[j]!=c[j]: temp+=1 if temp>1: break if temp==1: ans.append(i+1) elif len(b)+1 == len(c): temp = -1 temp1 = -1 for j in range(len(b)): if b[j]==c[j]: continue else: temp = j break if temp!=-1: for j in range(temp+1,len(b)): if b[j-1]!=c[j]: temp1 = 0 break if temp1==-1 or temp == -1: ans.append(i+1) elif len(c)+1 == len(b): temp = -1 temp1 = -1 for j in range(len(c)): if b[j]==c[j]: continue else: temp = j break if temp!=-1: for j in range(temp+1,len(c)): if b[j]!=c[j-1]: temp1 = 0 break if temp1==-1 or temp == -1: ans.append(i+1) print(len(ans)) print(*ans)
      
»
8 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I failed 5 times in task C,what should I do?hjqhs