Shayan's blog

By Shayan, history, 6 months ago, In English
  • Vote: I like it
  • +126
  • Vote: I do not like it

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

Why are the video editorials (made by Shayan, who to my knowledge had no relationship with the problemsetting of today's round) being downvoted? Anyway, thank you Shayan for these video editorials. Always appreciate them.

»
6 months ago, # |
Rev. 2   Vote: I like it +17 Vote: I do not like it

All those downvotes are coming from the people who craved these good solutions during the contest.

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

Great explanation for problem E, very easy to understand. I think that if the problem statement was clearer with saying that the special balls were on the first k positions there would be more ACs.

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

    They already said ' The first k balls are special'. Problem being they wrote it in input section of the problem.

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

thanks

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

Thanks for these video solutions Shayan . Helped a lot!

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

Hi Shayan,

For problem F, you said that, while counting the subarrays having xor value less than k, there will be a index j for index each index i, such that all the subarray's xor values will be less than or equal to k. can you prove this ?

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

Can Anyone please help me understanding why my code is failing as tle on tc 16 ,though its a nlogn approach and should pass according to the constraints

include

include

include

include

include

using namespace std; typedef long long int ll;

ll bin(vector a,ll l,ll r,ll target){

ll si=l+1;
ll ei=r;
ll ans=-1;
while(si<=ei){
    ll mid=(si+ei)/2;

    if(a[mid]-a[l]>=target){
        ans=mid;
        ei=mid-1;
    }else{
        si=mid+1;
    }
}
return ans;

}

int main() {

ll t;
cin >> t;

while (t--) {
    ll n;
    cin>>n;
    vector<ll> arr1(n,0);
    vector<ll> arr2(n,0);
    vector<ll> arr3(n,0);
    ll i=0;
    ll j=0;
    ll k=0;
    double tot=0;
    for(ll i=0;i<n;i++){
        cin>>arr1[i];
        tot+=arr1[i];
    }
    for(ll i=0;i<n;i++){
        cin>>arr2[i];
    }
    for(ll i=0;i<n;i++){
        cin>>arr3[i];
    }
    tot=ceil(tot/3);
    for(ll i=1;i<n;i++){
        arr1[i]=arr1[i-1]+arr1[i];
        arr2[i]=arr2[i-1]+arr2[i];
        arr3[i]=arr3[i-1]+arr3[i];
    }

    vector<pair<ll,ll>> ans;
    for(ll i=0;i<n;i++){
        if(arr1[i]>=tot){
            ll j=bin(arr2,i,n-1,tot);

            if(j!=-1){
                ll k=arr3[n-1]-arr3[j];
                if(k>=tot){
                    ans.push_back({0,i});
                    ans.push_back({i+1,j});
                    ans.push_back({j+1,n-1});
                    break;
                }
            }
            j=bin(arr3,i,n-1,tot);
            if(j!=-1){
                ll k=arr2[n-1]-arr2[j];
                if(k>=tot){
                    ans.push_back({0,i});
                    ans.push_back({j+1,n-1});
                    ans.push_back({i+1,j});
                    break;
                }
            }
        }
        if(arr2[i]>=tot){
            ll j=bin(arr1,i,n-1,tot);

            if(j!=-1){
                ll k=arr3[n-1]-arr3[j];
                if(k>=tot){

                    ans.push_back({i+1,j});
                    ans.push_back({0,i});
                    ans.push_back({j+1,n-1});
                    break;
                }
            }
            j=bin(arr3,i,n-1,tot);
            if(j!=-1){
                ll k=arr1[n-1]-arr1[j];
                if(k>=tot){

                    ans.push_back({j+1,n-1});
                    ans.push_back({0,i});
                    ans.push_back({i+1,j});
                    break;
                }
            }
        }
        if(arr3[i]>=tot){
            //cout<<arr3[i]<<" "<<tot<<endl;
            ll j=bin(arr1,i,n-1,tot);

            if(j!=-1){
                ll k=arr2[n-1]-arr2[j];
                if(k>=tot){

                    ans.push_back({i+1,j});
                    ans.push_back({j+1,n-1});
                    ans.push_back({0,i});
                    break;
                }
            }
            j=bin(arr2,i,n-1,tot);
            if(j!=-1){
                ll k=arr1[n-1]-arr1[j];
                if(k>=tot){

                    ans.push_back({j+1,n-1});
                    ans.push_back({i+1,j});
                    ans.push_back({0,i});
                    break;
                }
            }
        }
    }
    if(ans.size()>=3){
        for(ll i=0;i<3;i++){
            cout<<ans[i].first+1<<" "<<ans[i].second+1<<" ";
        }
        cout<<endl;
    }
    else{
        cout<<-1<<endl;
    }

}
return 0;

}

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

How about moving these wonderful video into China. They really benefits a lot!

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

    But it's a pity that I can't use VPN.

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

      What exactly do you mean by moving it to China. You mean move it to another platform instead of YT?

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

        Youtube is blocked in China. I guess he is saying to upload the editorials on BiliBili as well.

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

          I see. If that is the case, I will try to move the videos to another platform.

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

          Yeah!