Codeforces Round 837 Div 2 | Problem B : Hossam And Friends Solution | Newton School

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

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

  • @KaranMashru
    @KaranMashru ปีที่แล้ว +6

    (Subscribe for more such videos)
    Code :
    #include
    using namespace std;
    #define ll long long
    int main()
    {
    ll t, n, m, i, j, ans;

    cin>>t;

    for(;t--;)
    {
    ans=0;

    cin>>n>>m;

    ll first[n+1];

    for(i=0; i>i>>j;

    if(i>j){
    swap(i, j);
    }

    first[i]=min(first[i], j);
    }

    for(i=n-1; i>=1; i--)
    {
    first[i]=min(first[i], first[i+1]);
    }

    for(i=1; i

    • @JiteshKumar-lf6tv
      @JiteshKumar-lf6tv ปีที่แล้ว

      Make video on sum of cubes question in December long contest in Codechef

  • @Rajat_maurya
    @Rajat_maurya ปีที่แล้ว +6

    Bhai app kya mast breakdown karte ho ❤🙏

  • @beinghappy9223
    @beinghappy9223 ปีที่แล้ว +5

    Concept of suffix is brilliant

  • @SuccessAccount-c4v
    @SuccessAccount-c4v 3 หลายเดือนก่อน

    best explanation ever

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

    thankyou so much sir

  • @Bharat_Rider
    @Bharat_Rider 9 หลายเดือนก่อน

    Thaks bro❤

  • @aayushpatel6554
    @aayushpatel6554 ปีที่แล้ว +3

    Really good problem

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

    Summary of Concept:
    - Understanding the problem
    - you have to identify total number of subsegments where every pair in that subsegment are friends
    Let's take an example for that
    n is 5
    m is 3
    1 2
    2 3
    4 5
    Let's go step by step
    let's everyone are in standing in sequence from 1 to n
    - We will calculate nearest right which is not friend
    - for 1 it is 2, for 2 it is 3, for 4 it is 5 and for 5 everyone are friends
    Since we need to check between a and b where anything between them are not pairs to identify nearest right which is non friend, we'll loop backwards:
    - For 5 it's nearest friend on right is at 6,
    - For 4 it's nearest friend is at 4 itself
    - For 3 it's nearest friend is at 4
    - For 2 it is 2 itself
    - For 1 it is 1 itself
    Now calculating total subsegments it would be:
    1,2,3,(3,4),4,5 total 6
    please correct/improve if possible

  • @RAHUL-gf3ft
    @RAHUL-gf3ft ปีที่แล้ว +1

    brilliant explanation sir.

  • @methamphetamine36a10
    @methamphetamine36a10 8 หลายเดือนก่อน

    very nice explanation, great work 🖐🤚

  • @beinghappy9223
    @beinghappy9223 ปีที่แล้ว

    Amazing explanation

  • @Nikhilsainiharidwar
    @Nikhilsainiharidwar ปีที่แล้ว +6

    I almost done it , if I had more 5 minutes left in contest.🥺

    • @codingcommunitynewtonschoo8582
      @codingcommunitynewtonschoo8582  ปีที่แล้ว +2

      Better next time ✌

    • @Nikhilsainiharidwar
      @Nikhilsainiharidwar ปีที่แล้ว +1

      @@codingcommunitynewtonschoo8582 Hmm🙂

    • @Utkarshgg
      @Utkarshgg ปีที่แล้ว +1

      Same bhai, almost code likh diya tha bas halka sa last me rehgya coz A me bhut time laggya tha...usme time bachta too ho jata ye

    • @Nikhilsainiharidwar
      @Nikhilsainiharidwar ปีที่แล้ว +1

      @@Utkarshgg A m Kitna Time laga

    • @Utkarshgg
      @Utkarshgg ปีที่แล้ว +1

      @@Nikhilsainiharidwar I spent almost more than a hour on A, last me pata chala n ko long long Krna tha...idk why..n ki limit 10^5 thi jabki...n ko long kiya aur code tab jaake chala...around 50 mins Tak pretest 3 pe WA aarha tha

  • @Anonymous____________A721
    @Anonymous____________A721 8 หลายเดือนก่อน

    Cant we do by sliding window and Binary search?

  • @rudranilacharya5293
    @rudranilacharya5293 ปีที่แล้ว +10

    was able to do it but in three wrong attempts ,was quite a good problem for b, do you agree?

  • @utsavaggrawal2697
    @utsavaggrawal2697 ปีที่แล้ว

    Thanks a lot
    Plz upload c also

  • @itz_me_imraan02
    @itz_me_imraan02 ปีที่แล้ว

    This is my simple version of code!!
    void solve(){
    int n,m;
    cin>>n>>m;
    vector prev(n+2,0);
    int ans(0);
    int last = 0;
    for(int i=0;i>x>>y;
    if(x>y) swap(x,y);
    prev[y] = max(prev[y],x);
    }
    for(int i=1;i

  • @rishabhjajoriya2821
    @rishabhjajoriya2821 ปีที่แล้ว

    which concept have you used in the problem above??? is it in EDU section of codeforces??

  • @matuchaudhary5200
    @matuchaudhary5200 ปีที่แล้ว +4

    iski difficulty kitni hogi.

  • @anshulagarwal6682
    @anshulagarwal6682 ปีที่แล้ว +1

    Please make video for Problem D and E

  • @JiteshKumar-lf6tv
    @JiteshKumar-lf6tv ปีที่แล้ว +1

    Anyone knows answer of sum of cubes question in December long contest in Codechef
    Anyone knows answer of sum of cubes question in December long contest in Codechef
    Anyone knows answer of sum of cubes question in December long contest in Codechef
    Anyone knows answer of sum of cubes question in December long contest in Codechef
    Anyone knows answer of sum of cubes question in December long contest in Codechef
    Anyone knows answer of sum of cubes question in December long contest in Codechef
    Anyone knows answer of sum of cubes question in December long contest in Codechef

  • @girishbhargava6367
    @girishbhargava6367 ปีที่แล้ว +1

    What would be the expected rating of this question?

  • @Aryan-ix6gz
    @Aryan-ix6gz ปีที่แล้ว +1

    C ?

  • @gauravgautam5963
    @gauravgautam5963 ปีที่แล้ว

    ♥♥♥♥♥♥

  • @SatyamKumar-th7dm
    @SatyamKumar-th7dm ปีที่แล้ว

    Sir if 7 8 are not friend in the above example then how can 5- 8 be good subarray?

    • @codingcommunitynewtonschoo8582
      @codingcommunitynewtonschoo8582  ปีที่แล้ว

      When did I said so ? Can you specify the exact time in the video you are referring to ?

    • @adityaverma4902
      @adityaverma4902 ปีที่แล้ว

      @@codingcommunitynewtonschoo8582 at 15:20

    • @adityaverma4902
      @adityaverma4902 ปีที่แล้ว

      yeah am also confused in this :((

    • @dilsedhoni9229
      @dilsedhoni9229 ปีที่แล้ว

      @@codingcommunitynewtonschoo8582 Pl clarify sir.

    • @codingcommunitynewtonschoo8582
      @codingcommunitynewtonschoo8582  ปีที่แล้ว +1

      If we talk about the example taken at 15:20, for subarrays starting with index 5, further invalid ending index is 10. So starting with index 5, number of valid subarrays are 10-5=5. These are [5,5], [5,6], [5,7], [5,8], and [5,9].
      I hope this will help and make the point clear.

  • @Now_I_am_all_fired_up
    @Now_I_am_all_fired_up ปีที่แล้ว

    Wrong Code :::--- But i try it :-
    import java.util.*;
    public class Practice {
    public static void main(String[] args) {
    Scanner scan= new Scanner(System.in) ;
    int testcases = scan.nextInt() ;
    while(testcases--> 0) {
    int n = scan.nextInt() ;
    int m = scan.nextInt() ;
    HashMap map = new HashMap() ;
    int a , b ;
    for(int i=0 ;i