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

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

We will hold UNIQUE VISION Programming Contest 2024 Spring(AtCoder Beginner Contest 346).

We are looking forward to your participation!

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

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

Problem E is almost the same as 2023 Chinese NOI Spring Test Problem A. 涂色游戏 (paint), and is an easy version of LGR-162-Div.3 Problem D. 头 which I coauthored.

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

Please, can somebody tell me why this fails on F it literally binary searches the first left position to place "K" characters for every character in T. These contests are literally implementation only and I hate every minute of it.

16xAC 37xWA Link

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

I deducted the n^2 brute force solution mentioned at the end of G's editorial in 5 min, but just can't find a way to use a data structure to optimize it:( maybe i just ain't Chinese enough:P

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

wtf is F, I cannot understand why this fails: binsearch on K, for checking each character, binsearch again on how far we have to go

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

Is F binary search on answer and for each search, you binary search to find when you have enough letters? My solution was n(logn^2) but it TLEs on a couple cases.

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

    Binary search for problem F will work perfectly. I used binary search for problem F and got accepted.

    Here is my submission link : https://atcoder.jp/contests/abc346/submissions/51615694

    Let, p = s.size() and q = t.size()

    Then, time complexity : O(q * log(1e17) * log(p))

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

    Sorry for necroposting. I've just got TLE with your solution (which is also the intended one), I failed to optimize the constant, so I decided to write $$$O(n \log(ns))$$$, which is not that different.

    Fast solution
»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve D using DP ?

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

    you can do it with prefix sum

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

      can u explain prefix sum approach?

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

          sorry i really not getting your ideas can you explain more?

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

            you have to make string such that s[i] == s[i + 1] for exactly one i and the const should be minimum the idea is calculate cost for all possible i for both cases s[i] == 1 and s[i] == 0

            suppose we choose s[i] == 0 and i is odd
            now on the left <= i
            all 1's should occur at even position
            all 0's should occur at odd position
            
            on right >= i + 1
            all 1's should occur at odd position
            all 0's should occur at even position
            
            total cost = cost of making left + cost of making right
            
            similarly do it for s[i] == 1
            
            and the ans will be min cost considering all possible i for both cases
            
  • »
    »
    2 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

how to do D with dp?

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

    $$$dp[pos][prev][count]$$$

    pos = current position

    prev= value of previous character

    count = min( 2 ,count of $$$1 \le i \le n-1$$$ where $$$s_i=s_i+1$$$)

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

      for s[i] == s[i + 1] you just have to make sure either on the left for all k <= i parity of k == s[k] and on the right k >= i + 1 parity of k != s[k] or vice versa

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

      i am getting wrong on 3 test cases. What have i missed?

      Code

      https://atcoder.jp/contests/abc346/submissions/51621500

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

Solved all problems after so many contests, thank you for the contest

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

I have an edge case for problem F.

testcase :

2

aaa

aa

expected output : 3

But output of my accepted code for this testcase is 1. So, my code should got WA verdict. But my code got accepted.

Here is my submission link : https://atcoder.jp/contests/abc346/submissions/51615694

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

I have a question for problem B. I solved it in this manner: https://atcoder.jp/contests/abc346/submissions/51573486.

I was curious though, what if the values of W and B are very large(upto 1e18 or 1e9). In that case how will I be able to approach the problem. Is that even solvable? I am not able to think of any solution .Any help would be appreciated. Thank you

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

    Iterate over all starting points on the string and calculate how many strings you need for b since there are less occurences of b in the strings and then iterate over the remainder of the string.

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

    yes

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

In B, how answer is "No" for W=7,B=5???

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

absolutely interesting problem, G is hard but the tutorial is very clear.

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

Can anybody tell me why this code is giving RE in problem D. Link to solution: https://atcoder.jp/contests/abc346/submissions/51621300

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

For D, I don't really get why this (http://atcoder.jp/contests/abc346/editorial/9651) is a correct solution. I don't understand how the answer is computed. I thought that if n is even, then the series first character must be different than the last character, so ans = min(ans, l0[i] + g1[i]) and ans = min(ans, l1[i] + g0[i]). If n is odd then the first and last characters are the same so ans = min(ans, l0[i] + g0[i]) and ans = min(ans, l1[i], g1[i]).

However I see that doesn't matter for the solution. I'm confused — can anybody explain it to me?

  • »
    »
    2 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    Here is the crux of the idea
»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can i do problem G by taking number of elements to right until not finding current element and left and add to result like res+=l*r is this wrong approach please help me

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

There is something wrong with my submission on F. Can anyone help me? Many thanks. https://atcoder.jp/contests/abc346/submissions/51648515

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

This solution fails on only one test case could someone help? https://atcoder.jp/contests/abc346/submissions/51666225