atcoder_official's blog

By atcoder_official, history, 7 months ago, In English

We will hold Panasonic Programming Contest 2025(AtCoder Beginner Contest 427).

We are looking forward to your participation!

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

»
7 months ago, hide # |
 
Vote: I like it -7 Vote: I do not like it

I really look forward to this contest.

»
7 months ago, hide # |
 
Vote: I like it -7 Vote: I do not like it

hopefully can go outside of beginner zone today

»
7 months ago, hide # |
 
Vote: I like it -23 Vote: I do not like it

qp

»
7 months ago, hide # |
 
Vote: I like it -9 Vote: I do not like it

i hope i can solve C

»
7 months ago, hide # |
 
Vote: I like it -6 Vote: I do not like it

Gl everyone!

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hope I could solve F

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

In question C, is it necessary for the graph to be connected? Not mentioned in the question but my solution which should only work for connected graphs is accepted.

»
7 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

Bad round

»
7 months ago, hide # |
 
Vote: I like it +26 Vote: I do not like it

E is totally SHIT

»
7 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

Not bad. Decent round, decent problems. How to solve $$$F$$$?

  • »
    »
    7 months ago, hide # ^ |
     
    Vote: I like it +23 Vote: I do not like it

    Considering Meet-in-the-Middle. In fact there's only $$$O(1.618^{N})$$$ subsequences satisfying the conditions. Meet-in-the-Middle with $$$O(1.618^{N/2})$$$ can pass.

    • »
      »
      »
      7 months ago, hide # ^ |
       
      Vote: I like it +21 Vote: I do not like it

      I had to push hard enough to make my MITM pass, changing map to unordered map helped and i am not sure why :)

    • »
      »
      »
      7 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Who can explain why this algorithm is $$$O(1.618^{N/2})$$$? Thx.

      • »
        »
        »
        »
        7 months ago, hide # ^ |
         
        Vote: I like it +19 Vote: I do not like it

        In fact when you have $$$n\ge2$$$ numbers last, you have two choices:

        • choose this number, then you have $$$n-2$$$ number to choose.

        • Don't choose this number, then you have $$$n-1$$$ number to choose.

        So the number of solutions of $$$n$$$, like $$$fib_n$$$, is $$$O(1.618^n)$$$.

        Sorry for my poor prounce because I'm not well in English.

»
7 months ago, hide # |
 
Vote: I like it +30 Vote: I do not like it

Gosh, I thought Alice and Bob operate $$$K$$$ times in total by mistake. This wasted me 10 minutes :(

»
7 months ago, hide # |
Rev. 2  
Vote: I like it +16 Vote: I do not like it

Wonder why my meet-in-middle for problem F getting TLE. It only takes <250ms when I locally tested the extreme data.

Submission

upd: It passed after I changed map to unordered_map. Please make n=40 or n=50 instead of 4s time limit next time :(

  • »
    »
    7 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Could you please explain your approach?

    • »
      »
      »
      7 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      DFS Search for left $$$\frac{n}{2}$$$ elements, calculate sum and store them into map.

      DFS search for right $$$\frac{n}{2}$$$ elements, calculate sum and check map to update answer.

      Besides, maintain a flag to prevent choosing adjacent elements at the barrier.

      Although $$$\frac{n}{2}=30$$$, the number of valid subsequence isn't very much, since we have the limit of not choosing adjacent elements.

  • »
    »
    7 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Same for me. No idea why it makes such big difference in this case. Spent quite a while on it

  • »
    »
    7 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it +25 Vote: I do not like it

    With $$$N=40$$$ or maybe even $$$N=50$$$, $$$O(2^{N/2})$$$ also passes, removing the most essential observation part...

    • »
      »
      »
      7 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      You can anyways do it without the observation by dividing into 3 segments.

      • »
        »
        »
        »
        7 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        How will you combine the 3 segments contribution?

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

          like if you divide it into N=1 to 15, 16 to 30, 31 to 60, find out the non-adjacent subsequences for each, when combining what matters is whether left or right end of the segment are included in subsequence or not, then you can combine easily.

          • »
            »
            »
            »
            »
            »
            7 months ago, hide # ^ |
             
            Vote: I like it +1 Vote: I do not like it

            How do you combine easily?

          • »
            »
            »
            »
            »
            »
            7 months ago, hide # ^ |
             
            Vote: I like it 0 Vote: I do not like it

            Yeah how will you combine "easily"? I could not find any idea of combining 3 splits, we have 3 variables and we need to fix atleast 2 of them. I would appreciate if you could provide a working code.

            • »
              »
              »
              »
              »
              »
              »
              7 months ago, hide # ^ |
               
              Vote: I like it 0 Vote: I do not like it

              You know what i just realized that my time complexity bound still needs the fib observation, i am dumb.

  • »
    »
    7 months ago, hide # ^ |
     
    Vote: I like it +21 Vote: I do not like it

    you can also use vector and lower_bound instead of map, it is generally almost always faster

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Bad I feel so difficulty.

»
7 months ago, hide # |
 
Vote: I like it +19 Vote: I do not like it

F<E.

  • »
    »
    7 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    E is just BFS, while F is MITM DP. Why so many people think E>F?

    • »
      »
      »
      7 months ago, hide # ^ |
       
      Vote: I like it +11 Vote: I do not like it

      You can hardly see a $$$O((nm)^3)$$$ BFS in a contest. On the other hand, mitm is more popular.

    • »
      »
      »
      7 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Do you call every problem that eventually can be solved just using bfs, a "just BFS"?

      • »
        »
        »
        »
        7 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        I solved more BFS than MITM in contests. So, probably it's more intuitive for me. Also, I find DP a bit harder than BFS. So, this might be just me. But I get your point.

    • »
      »
      »
      7 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Because E is harder to implement, while both problems are straightforward.

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

hard men

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

In E, I assumed that the trash removal process would comprise of atmax 8 steps (2 in each direction, steps means removing in the direction till I cannot or the there are no trash). This is 39/43. Is there any counter example? Submission

UPD: Found :)

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Anyone would help me?4WA on E. It almost kills me to find the BUG.

Submission

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

For F, Meet in Middle Using Map Got TLE but using Unordered Map Got Accepted. Why so??

  • »
    »
    7 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it 0 Vote: I do not like it

    Because the time-complexity of std::unordered_map is $O(1)$,while the time-complexity of std::map is $O(\log n)$,so in large datas, unodered_map may faster than map.

    sorry for my poor english:(

»
7 months ago, hide # |
Rev. 2  
Vote: I like it +27 Vote: I do not like it

Good contest but many cheaters ranked high:

plz ban them atcoder_official to maintain a good competition environment thank you

»
7 months ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

why DEF are all search problems ???

i suppose it's meaningless to set many search problems (although some of them are tricky), and there should be more data structures or math problems, or there are no difference between the performance of who has already trained for some years and who has just learned some basic algorithms, and the rating system is also meaningless then.

  • »
    »
    7 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it +22 Vote: I do not like it

    Why you think D is a search problem? In my opinion, it's a dynamic programing problem. However, I think that D is more difficult than E,F:(

    Or could you share your search solution about D?

    upd: he tells me that he used Memoization Search and he thought it's a kind of search.

»
7 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

You are right, but why C,D,E,F are all brute forces problems?

»
7 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

how D??!!!

i try to use dp[t][u] which means the chess in node u and round in t player (t=0 Alice and t=1 Bob),

and init dp chess on node 'A' dp[0 or 1][u] = (s[u]=='A').

Then i try to do:

if t==0 (Alice turn), dp[0][u] = OR of dp[1][v] for all v next to u

if t==1 (Bob turn), dp[1][u] = AND of dp[0][v] for all v next to u

i repeat this K times thinking it simulates K moves each player.

But it gives WA on some tests. I feel like it only simulates one step per player, not full K steps.

how should i change my dp or transitions to handle each player moving K times properly?

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Submitted D with 1 second left only to be TLE'd in a single test case due to the use of set instead of unordered_set :( also what is this C lol I used a randomized algorithm to solve it lmao

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

ABC247E I’m solving ABC427 E – Wind Cleaning and 4 test cases keep failing; can anyone give me a hint about the edge cases I’m missing?

  • »
    »
    7 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I think that in those cases T becomes dirty by already removed trash.

    • »
      »
      »
      7 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Thank you for your reply.But I think T only gets dirty if there’s no path for the trash to reach the grid boundary, in which case my BFS should return no solution.

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

      Oh, you are right. I actually constructed a counterexample: 3 7 ### #T# #.# #.# #.# #.# #.# 3 The answer should obviously be different.

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Is possible to solve problem C for bigger $$$N$$$? how large can $$$N$$$ be?

»
7 months ago, hide # |
 
Vote: I like it +52 Vote: I do not like it

WORST PAIN EVER

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The time limit for F should be 5 sec. 4 sec is too strict.

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I am not able to get any ideas about C? Any hints??

  • »
    »
    7 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it
    Hint
    Solution
    • »
      »
      »
      7 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Oh I see thanks, thanks, idk why I didn't think it according to coloring, I was just focusing on edges removal smh

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The idea for G is really new to me (that we find an equivalent sequence). Is it something general in disguise? If not, can you share some problems on similar ideas?

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

About E: Why the efficiency of map and unordered_map differs so much?

»
7 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

This user submitted 4 completly different code in the last 20 minutes. And these, especially the last submission, are very strange.

https://atcoder.jp/contests/abc427/submissions?f.Task=&f.LanguageName=&f.Status=&f.User=sry0417

I think he use AI.

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

There is a mistake in the english editorial for problem D. Spent 30 minutes staring because it didn't make sense, I had to use my browsers translator on the japanese editorial to spot the error. Please fix.

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Bad editorial for D in English. I think that for every $$$i$$$ that satisfy $$$i \equiv 1 \pmod 2$$$, $$$dp_{i, j}$$$ is false if and only if $$$dp_{i + 1, v}$$$ is false and there exists an edge between $$$v$$$ and $$$j$$$, and $$$dp_{i, j} = $$$ true otherwise. However, the Japanese editorial is correct, so change the English version please.