### StellarSpecter's blog

By StellarSpecter, history, 13 days ago,

Why Edu Round Delta has not been updated yet?

Also, When I'm trying to submit my code, it says it's in queue.(It's been so long)

Does anyone know when will it get fixed ?

• -7

By StellarSpecter, history, 2 weeks ago,

As a newbie, I want expert opinions on who is the best explainer of contest problems on youtube.

Is it aryanc403 or Shayan or someone else.

Thanks

• +9

By StellarSpecter, history, 2 weeks ago,

I've been wondering for soo long about this. Some people get -ve delta after skipped contest while some get " — " (unrated) shown in their contests list. Why is that so ?

Thanks!

• +3

By StellarSpecter, history, 5 weeks ago,

Why is this happening, please i have been stuck on this for a day now. I've searched everywhere. This is the problem DP problem -> Palindrome partitioning

I couldn't solve it and looking at solutions i couldn't understand why some solution pass and some do not, Please help me with it. I want to understand why iterative gives TLE and recursive solution passes.

Thanks.

Iterative code ->

class Solution {
public:
int minCut(string s) {
int n = s.size();
vector<vector<int>>dp(n,vector<int>(n));
vector<vector<int>>ck(n,vector<int>(n));
for(int i=0;i<n;i++) ck[i][i]=1;
for(int i=n-1;i>=0;i--){
for(int j=i+1;j<n;j++) {
if(j-i==1&&s[i]==s[j]) ck[i][j]=1;
else ck[i][j]=ck[i+1][j-1]&&(s[i]==s[j]);
}
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++) {
if(ck[i][j]||(i==j)) dp[i][j] = 0;
else dp[i][j] = j-i;
}
}
for(int i=n-1;i>=0;i--){
for(int j=i+1;j<n;j++){
if(ck[i][j]) {
dp[i][j]=0;
continue;
}
for(int k=i;k<j;k++){
if(ck[i][k]) dp[i][j]=min(dp[i][j],1+dp[k+1][j]);
}
}
}
return dp[0][n-1];
}
};


This code doesn't work fine and gives TLE.

class Solution {
public:
int solve(string &s,vector<vector<int>>&dp,vector<vector<int>>&ck,int i, int j){
int n = s.size();
if(i>=j) return 0;
if(dp[i][j]!=-1) return dp[i][j];
if(ck[i][j]) return dp[i][j] = 0;
int val = j-i;
for(int k=i;k<=j;k++){
if(ck[i][k]) val = min(val,1+solve(s,dp,ck,k+1,j));
}
return dp[i][j] = val;
}
int minCut(string s) {
int n = s.size();
vector<vector<int>>dp(n,vector<int>(n,-1));
vector<vector<int>>ck(n,vector<int>(n));
for(int i=0;i<n;i++) ck[i][i]=1;
for(int i=n-1;i>=0;i--){
for(int j=i+1;j<n;j++) {
if(j-i==1&&s[i]==s[j]) ck[i][j]=1;
else ck[i][j]=ck[i+1][j-1]&&(s[i]==s[j]);
}
}
return solve(s,dp,ck,0,n-1);
}
};


This code works fine and beats 90% of users on leetcode.

why is this happening, please i have been stuck on this for a day now. I've searched everywhere.

Thanks!

• 0

By StellarSpecter, history, 5 weeks ago,

I recently started doing 800 rated problems.

How do I improve when I can't solve? GCD,LCM, etc Math seems too hard.

• -8

By StellarSpecter, history, 5 weeks ago,

When was last plag check and when should be the next ?

I have no idea when they do it, can anyone tell me ?

Thanks!

• -21

By StellarSpecter, history, 5 weeks ago,

Hello, I have no friends irl and that's why my friend's standing page in contests is filled with tourist and me only.

Anyone who is willing to be my friend please let me know, I will add you back and we can talk a little when i'm in trouble.

Thanks alot!

PS: Don't hate on this newbie. PS: Good luck everyone for tomorrow's Div.2

• +49

By StellarSpecter, history, 6 weeks ago,

I can't stand the wait of ~ 1 week for the contests. Why there are so few contests like this month only has 4??

Last one was on 30th June, and now on 7th july then 15th July :( . I can't just keep practicing for 7 days straight I need something to practice and test upon. No, i can't keep on giving virtuals either. I have to go back to college from 25th July and I won't be able to dp cp after that. Im tired of doing leetcode only.

MikeMirzayanov It's a humble request. @every_LGM_IGM_GM_M_CM

TLDR: Please make more contests.

THANKS!

• -40

By StellarSpecter, history, 6 weeks ago,

I can't understand why this solution 268341805 is passing but this 268341778 is giving WA on testcase 2, both codes are 99% same.

TLDR: I am writing down the part of my code which I changed so that my code got AC.

Please all the help would be greatly appreciated. Thank you so much in advance.

auto it = upper_bound(v.begin(),v.end(),val);
if(it!=v.end()&&it!=v.begin()) {
ans=min(ans,min(abs(*(it)-val),abs(*(--it)-val))); // old
}
else if(it==v.end()) {
ans = min(ans,abs(*(--it)-val));  //old
}
else if(it==v.begin()) {
ans=min(ans,abs(*(it) - val));  //old
}

auto it = upper_bound(v.begin(),v.end(),val);
if(it!=v.end()&&it!=v.begin()) {
auto it2 = it; it--;                                   // new
ans=min(ans,min(abs(*it2-val),abs(*(it)-val)));
}
else if(it==v.end()) {
it--;
ans = min(ans,abs(*(it)-val));                        // new
}
else if(it==v.begin()) {
ans=min(ans,abs(*it - val));                         // new
}

• +2

By StellarSpecter, history, 7 weeks ago,

What did I do to deserve so many downvotes on each and every thing I have posted comments, blogs, etc.

When i ask questions -> I get downvoted. I ask for tips -> I get downvoted.

I checked, I'm the 35th lowest rated with -62 on the whole platform. :(((

Please STOP this ratism.

• -23

By StellarSpecter, history, 7 weeks ago,

I solved it as if y<0 and abs(y) >= abs(x) cout<<"NO"<<endl;

But this did not work even after trying so long.

why is this incorrect can anyone help this newbie?

THANKS!

• -6

By StellarSpecter, history, 7 weeks ago,

I SOLVED PROBLEM C IN TODAY"S DIV.2 :((((

WHY MY RATING IS STILL SAME WHILE FOR EVERYONE ELSE THERE IS A DELTA>0

• -20

By StellarSpecter, history, 7 weeks ago,

Help me solve this problem please ->

**** **** There is an array of n elements, initially filled with zeros. You need to write a data structure that processes two types of queries: assign value v to all elements on the segment from l to r−1, find the sum on the segment from l to r−1.

Input

The first line contains two numbers n and m (1≤n, m≤100000), the size of the array and the number of operations. The following lines contain the description of the operations. The description of each operation is as follows: 1 l r v: assign value v to all elements on the segment from l to r−1 (0≤l<r≤n, 0≤v≤109). 2 l r: find the sum on the segment from l to r−1 (0≤l<r≤n).

Output

For each operation of the second type, print the corresponding value.

• -35

By StellarSpecter, history, 7 weeks ago,

There is an array of n elements, initially filled with zeros. You need to write a data structure that processes two types of queries:

add v to the segment from l to r-1, find the sum on the segment from l to r−1.

Input The first line contains two numbers n and m (1≤n,m≤100000), the size of the array and the number of operations. The following lines contain the description of the operations. The description of each operation is as follows:

1 l r v: add v to the segment from l to r−1 (0≤l<r≤n, 0≤v≤105). 2 l r: find the sum on the segment from l to r−1 (0≤l<r≤n).

Output For each operation of the second type, print the corresponding value.

My Code:

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD=1e9+7;

const int N = 1e5;
ll seg_tree[4*N];
ll lazy[4*N];

void push(int l, int r, int node){
if(l!=r&&lazy[node]!=0){
int m = l + (r-l)/2;
seg_tree[2*node]+=(m-l+1)*lazy[node];
seg_tree[2*node+1]+=(r-m)*lazy[node];
lazy[2*node+1]+=lazy[node];
lazy[2*node]+=lazy[node];
lazy[node]=0;
}
}

void update(int l, int r, int i, int j, int val, int node){
if(i>r||j<l) return;                    // OR l>r
if(i<=l&&j>=r){
seg_tree[node]+=(r-l+1)*val;
lazy[node]+=val;
return;
}
push(l,r,node);
int m = (l+r)/2;
update(l,m,i,min(j,m),val,2*node); update(m+1,r,max(i,m+1),j,val,2*node+1);
seg_tree[node]=seg_tree[2*node]+seg_tree[2*node+1];
}

ll query(int l, int r, int i, int j, int node){
if(i>r||j<l) return 0;
if(l>=i&&r<=j){             // OR if(l>=i&&r<=j) returns seg_tree[node];    -> both are correct.
return seg_tree[node];
}
push(l,r,node);
int m = (l+r)/2;
return query(l,m,i,min(j,m),2*node) + query(m+1,r,max(i,m+1),j,2*node+1);
}

int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m; cin>>n>>m;
while(m--){
int t; cin>>t;
if(t==1){
int i,j,v; cin>>i>>j>>v;
update(0,n-1,i,j-1,v,1);
}
else{
int i,j; cin>>i>>j;
cout<<query(0,n-1,i,j-1,1)<<'\n';
}
}
}


24 hours and couldn't figure out what's wrong in my code. Can anyone help me decode what's wrong with my solution ? I'm getting wrong answer on test case 61 with '!' symbol.

• -14

By StellarSpecter, history, 2 months ago,

I bet it's too hard for you to solve.

Go give it a try:

SMASH ME

• -18

By StellarSpecter, history, 2 months ago,

If you can give some tips/advice it would be really helpful.

I suck at problem solving and i get tired of solving the same problem over and over again and in the end i quit.

thanks in advance for the tips.

• -5

By StellarSpecter, history, 2 months ago,

How is it possible?

Everyone's rating change has been made but my rating is still the same and it shows not even +0 in the contest rating change page.

• -23

By StellarSpecter, history, 2 months ago,

Even after trying so hard in today's Div.4 I couldn't solve a single good problem.

Conclusion: I'm the problem.

Goodbye Cf, it's not for retards like me.

• -24