17

AtCoder Beginner Contest 242 Announcement - Codeforces

 2 years ago
source link: http://codeforces.com/blog/entry/100601
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

We will hold AtCoder Beginner Contest 242.

We are looking forward to your participation!

31 hour(s) ago, # |

Rev. 3  

-14

I'm not Red-y for this contest

29 hours ago, # |

Cpp20 when D:

28 hours ago, # |

What happened to the judge? It's so slow.

28 hours ago, # |

Long queue!

27 hours ago, # |

Problem C is not beginner friendly :(

26 hours ago, # |

Rev. 2  

-10

for Problem C:

10,11,12

21,22,23

32,33,34

43,44,45

54,55,56

65,66,67

76,77,78

87,88,89

98,99

for n=2, shouldn't the answer be 26 instead of 25(given in question)?

  • 26 hours ago, # ^ |

    You can't take 00 as a digit in the number.

    • 26 hours ago, # ^ |

      Thanks

26 hours ago, # |

How to solve D?

  • 26 hours ago, # ^ |

    Rev. 2  

    +3

    For t <= 62, you can imagine finding value on a binary tree. It the ith bit of k is 0, go left, else go right; For t > 62, since we have a tons of leading zeros in k (0000...), we can do binary lifting. Submission

    • 26 hours ago, # ^ |

      You don't even need to do binary lifting for t > 62. I think you can just convert the first character of string s (t — 62) % 3 times, taking the first character after the operation, and then do the procedure you described for t <= 62.

      • 26 hours ago, # ^ |

        Yeah, I over-killed it.

  • 25 hours ago, # ^ |

    What I did:

    First find out, which is the letter from the original string, that creates the block in which the char from the query will lie. This is realpos = pos / (1ull << it). Then determine the position inside this block, where the query will be. This is innerpos = pos % (1ull << it). (Special case for more than 63 iterations has to be implemented.)

    Now we know the letter from the original string. We take that as a base BB. Instead of "A->BC, B->CA, C->AB." I will use "A->AB, B->BC, C->CA." now. To account for this change we add the number of iterations to BB.

    Now we need to consider the innerpos. Which letter will be at this position? This hapens to be the count of set bits in innerpos in binary. So we just need to add __builtin_popcountll(innerpos) to BB.

    Then BB is the answer. https://atcoder.jp/contests/abc242/submissions/29884835

26 hours ago, # |

Today I used Mo's algorithm for the first time.

  • 26 hours ago, # ^ |

    Same dude, I was able to solve GG because of that, but not FF.

    • 26 hours ago, # ^ |

      I noticed that dush1729 solved it quite quickly, so decided to do G before F (which turned out to be not that difficult as well, just some combinatorics and inclusion-exclusion).

      • 26 hours ago, # ^ |

        Rev. 2  

        0

        Not being lazy paid off. I decided to finish my mo's template after I failed to solve abc238g

        • 26 hours ago, # ^ |

          Wait, it was Mo as well? I used a lazy segment tree from the AtCoder library: 28946126

          • 26 hours ago, # ^ |

            Sorry my bad. I meant 238g.

  • 26 hours ago, # ^ |

    Rev. 2  

    +8

    Yes, that was also exactly my experience! Didn't want E, couldn't F, saw G. Never did Mo before but it so much looked like Mo, so I had to do it.

    • 26 hours ago, # ^ |

      +1, E is such an overused type of problem. I guess it makes sense in a Beginner contest, but still makes me :meh: every time.

  • 26 hours ago, # ^ |

    I forgot to change the block size in my first submission in problem G but in fact, block size of 32 ran faster than 750. I don't know the reason why the solution was accepted...

    • 26 hours ago, # ^ |

      Probably because the time limit was 5 seconds lol

      • 26 hours ago, # ^ |

        with block size 32 it ran in 1381 ms and with 750 it ran in 1618 ms

26 hours ago, # |

How to solve H?

26 hours ago, # |

Rev. 2  

0

GG-Range Pairing Query There is no editorial yet

:/:/

How to solve GG? I wanted to come up with a Segment Tree solution but I failed when I wanted to find all the distinct numbers in range l...rl...r.

PS : Did anyone solved it with Segment Tree? Or it has different algorithm to solve it?

  • 26 hours ago, # ^ |

    Just use mo's algorithm. Whenever you add a number to a range, check if the count of the number is odd, and if so add one to the answer. Similarly, whenever you erase a number from a range, check if the count of the number is even, and if so remove one from the answer.

26 hours ago, # |

third one I did by using dp very cool one see once

Your code here...
public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));      
        StringTokenizer st;
             st = new StringTokenizer(br.readLine());
               int n = Integer.parseInt(st.nextToken())-1;
               long mod = 998244353L;
               long[][] dp = new long[n][9];
               dp[0][0] = dp[0][8] = 2;
               dp[0][1] = 3;
               dp[0][2] = 3;
               dp[0][3] = 3;
               dp[0][4] = 3;
               dp[0][5] = 3;
               dp[0][6] = 3;
               dp[0][7] = 3;
               for(int i = 1;i<n;i++){
                   for(int j = 0;j<9;j++){
                       if(j == 0){
                           dp[i][j] = (dp[i-1][j]%mod+dp[i-1][j+1]%mod)%mod;
                       }
                       else if(j == 8){
                           dp[i][j] = (dp[i-1][j]%mod+dp[i-1][j-1]%mod)%mod;
                       }
                       else{
                           dp[i][j] = (dp[i-1][j]%mod+dp[i-1][j-1]%mod+dp[i-1][j+1]%mod)%mod;
                       }
                   }
               }
              long ans = 0L;
              for(int i = 0;i<9;i++){
                  ans = (ans+dp[n-1][i])%mod;
              }
              bw.write(ans+"\n");
             bw.flush();
        }

26 hours ago, # |

For problem E I use digit DP on string. The states are dp[length][prefix_same][suffix_bigger]. Submission

  • 26 hours ago, # ^ |

    Rev. 5  

    0

    You can also do dp[index]dp[index], where dp[i]dp[i] denotes the number of lexicographically smaller strings for index i,1≤i≤(n+1)2i,1≤i≤(n+1)2. Finally, define tt as follow:

        string t = s;
        for(int i=1; i<=(n+1)/2; i++)
          t[n-i] = s[i-1];
    

    If the string tt is lexicographically smaller than ss, or with c++ you can just check if t<=st<=s, add 1 to the answer. submission

26 hours ago, # |

Does anyone think that F was way harder than G?? I almost took half of my time solving F, but solved G in a few minutes as I knew Mo's algorithm(which was very lucky). Looking at the number of people who solved F and G I guess most people would have felt similarly. Or, is there a simpler solution to F?

  • 26 hours ago, # ^ |

    My solution involves two steps, first calculating dp[r][c][k], which represents the number of possible covering of r x c with k rooks of a same color without leaving a row nor column empty, and then the second step was just simply iterating through number of rows and columns for black rooks and white rooks, and adding the value dp[rb][cb][b]×dp[rw][cw][w]×(nrb)×(n−rbrw)×(mcb)×(m−cbcw)dp[rb][cb][b]×dp[rw][cw][w]×(nrb)×(n−rbrw)×(mcb)×(m−cbcw) for each rw,rb,cw,cbrw,rb,cw,cb.

    • 25 hours ago, # ^ |

      I also had a similar solution, but the process of calculating dp[r][c][k] was very complex. I guess it was what made the problem so hard

      • 25 hours ago, # ^ |

        Ah, there was a fairly simple transition between dp states. All you had to do for calculating dp[r][c][k] is to first add (r×ck)(r×ck) and then ∀1≤i≤r,1≤j≤c∀1≤i≤r,1≤j≤c (excluding (i, j) = (r, c)) subtract dp[i][j][k]×(ri)×(cj)dp[i][j][k]×(ri)×(cj) from dp[r][c][k]. Hope this makes sense

        • 11 hours ago, # ^ |

          Thanks a lot for your hints. I didn't find out how to compute dp[r][c][k] during the last 20 minutes, but with your hints, I finally get it accepted after the contest.

  • 25 hours ago, # ^ |

    Simple problems of advanced tricks are often easier if you already know the technique.

26 hours ago, # |

It didn't count for the contest. Makes me so sad, that was the most clutch. It was a last second debugging and panic-submission. [May I get an F?]

But also it was way to complicatly implemented from my side. I though at first this has to be digit DP with some kind of state for the second half of the palindrome. But it was more like the simplest form of Digit DP (means, interpret the first half of the string as a number) plus checking whether the palindrome created by using the first half of the string is valid. If I had just thought about E more, then I guess I wouldn't have had this time problem.

26 hours ago, # |

It seems official solution of Ex is not min-max inclusion and exclusion?

25 hours ago, # |

Rev. 2  

0

hello, I was getting a runtime error when I was running code on vs code for n>=10^5, submssion I didn't submit the code because of this and after that contest when I submitted It got accepted but still got a runtime error for n>=10^5 on vs code. can someone explain why?

  • 23 hours ago, # ^ |

    You should modify stack size on your local device. Recursion sometimes give RE with not enough stack size.

25 hours ago, # |

How to Solve E ?? Please Explain in detail ... ;_;

  • 25 hours ago, # ^ |

    Try enumerating the first half of the palindrome.

25 hours ago, # |

why can't I see rankings by country?

  • 9 hours ago, # ^ |

    Since the last heuristic contest they've experienced server overload (or something like that) so sometimes they disabled ranking page. There also has been postponed contest around last week or two. I assume this functionality is temporarily disabled to cut performance cost, tho I'm not sure.

25 hours ago, # |

Really nice problems. For me the problems difficulty were F > D > E > G. Did anyone else felt the same way?

9 hours ago, # |

Rev. 2  

0

Problem E from this round was almost the same as Problem A from Kick Start Round C, 2021

Was this intentional?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK