Codeforces Round 949 Solution Discussion | ABCD

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 พ.ย. 2024

ความคิดเห็น • 14

  • @Ayushkumar-bq6vk
    @Ayushkumar-bq6vk 5 หลายเดือนก่อน +4

    my approach for b:
    to or all numbers from n-m to n+m, we just check the maximum index in bit representation of max(0,n-m) from right that is different from n+m; then just or n+m with the number with all the bits set from the right.
    Code:
    #include
    #include
    using namespace std;
    #define int long long
    signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--){
    int n,m;
    cin>>n>>m;
    if(n==0){
    if(m==0){
    cout

    • @SachinSingh-rj6wj
      @SachinSingh-rj6wj 5 หลายเดือนก่อน

      I also did that by the same approach 😅

  • @HarshSingh-qq2jf
    @HarshSingh-qq2jf 5 หลายเดือนก่อน

    My approach for B:-
    Let L and R differ at 6th bit, then from MSB to 7th bit, every thing will be same in L and R, at 6th bit, since L < R, L will have 0 and R will have 1 at 6th bit
    Now, since L to R is a range, we have ......1000000 as the smallest number having MSB to 7th bit similar to L and R because every number in this range will have same MSB to 7th bit, and we have ......0111111 as the largest number having MSB to 7th bit similar to L and R, and these two will give all bit from 6th to 0th as set in OR from L to R, and remaining MSB to 7th bit are same in all the numbers, so L|R will give that
    Final answer is (L | R | (2^i)-1 ) where i is one more than first different bit i.e. here 6+1 = 7, as this will give ......1111111
    Anyway the question is usually Div 2 C, but this time it was Div 2 B

  • @ronakjain8164
    @ronakjain8164 5 หลายเดือนก่อน

    My approach for B :
    we have range as n-m to n+m
    so for each bit from 0 to 30 I checked if it can be present in the range
    int res = 0;
    int back = 0;
    for(int bit = 0; bit >bit)&1){
    res += (1

    • @phoddaal7130
      @phoddaal7130 5 หลายเดือนก่อน

      Bro can you please elaborate more.

  • @rakshitjoshi823
    @rakshitjoshi823 5 หลายเดือนก่อน

    In Ques B: What is y_combinator that you used in segment tree?

    • @aryanc403
      @aryanc403  5 หลายเดือนก่อน

      Its just a fancy way to write recursive function.
      usaco.guide/general/lambda-funcs?lang=cpp

  • @anujverma9536
    @anujverma9536 5 หลายเดือนก่อน +2

    Bhai is B ne jo dimag kharab kra tha na mera ki kya batau. Btw love your content thank you.

  • @navinraj135
    @navinraj135 5 หลายเดือนก่อน

    How can you prove your solution will work always for C ?

    • @aryanc403
      @aryanc403  5 หลายเดือนก่อน

      Official editorial has a visual proof codeforces.com/blog/entry/129848

  • @Noobish_Monk
    @Noobish_Monk 5 หลายเดือนก่อน

    Didn't even solved E 🤦‍♂️

    • @aryanc403
      @aryanc403  5 หลายเดือนก่อน +2

      My skill issue tbh.

    • @plaintext7288
      @plaintext7288 5 หลายเดือนก่อน +4

      Wild comment