Taha1506's blog

By Taha1506, history, 5 days ago, In English

Hi!I was wondering wheter participating from iran to hashcode is forbidden or not.I don't see any rules in the site but there is no Country named iran in the registeration should I just pick a random country and participate?

Read more »

 
 
 
 
  • Vote: I like it
  • +26
  • Vote: I do not like it

By Taha1506, history, 4 weeks ago, In English

I was solving This problem and submitted 106080441.I am getting runtime errors on test 4.The codeforces diagnoser says it is because it is of integer overflow I changed everything to long long but it gives me again the same error.Can anyone say Whats wrong with my code please?Thanks.

Edit:Ok I got it I should have checked lx<a.size();

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Taha1506, history, 4 weeks ago, In English

I need to add some flags to compiler to avoid overflow or other stupid mistakes but I can't do it.I searched the methods in the net to find a solution for Clion but since I was very new to programming so I didn't understand well.Can anyone explain please?

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Taha1506, history, 7 weeks ago, In English

I was studing cp-algorithem web and I was trying to come up with 0-1 BFS by my self.I came up with the following algorithm:

We run a DSU to all edges with weight $$$0$$$ after that we come up with some components now for each edge with weight $$$1$$$ instead of adding edges between the original vertices $$$u,v$$$ we add edges between their leaders then apply a BFS to the leaders(with source vertex being the leader vertex of our source-vertex) only then the length of the path between $$$u$$$ and some source-vertex $$$v$$$ will be the length between leader of $$$v,u$$$.

This is probably not new.But I was wondering if this is faster or slower than the actual 0-1 BFS in CP?In terms of time complexity it is worse than the actual 0-1 BFS but since in competetive programming we are dealing with small numbers $$$\alpha (m,n)$$$ may be treated as a constant.Any idea on how to test this?

Read more »

 
 
 
 
  • Vote: I like it
  • +15
  • Vote: I do not like it

By Taha1506, history, 2 months ago, In English

Some time ago someone told me that when your choices are quite dependent to each other then using dp will be a great idea having this in mind it helped me to come up with the dp idea in a lot of problems in the first place.Yesterday I saw a problem that had dp solution see the link .I wasn't able to recognize it is a dp problem until the end of the contest.But a yellow coder seeing the problem in the first place told that it is a standard dp problem.So my question is how to recognize "Standard dp" problems?Can anyone tell me what property of the problem makes it a standard dp problem?Thanks in advance.

Read more »

 
 
 
 
  • Vote: I like it
  • +18
  • Vote: I do not like it

By Taha1506, history, 2 months ago, In English

Does anyone know how can I make a certain part of code always appear in Clion.And also how can I save a file as a template so that it appears without rewriting it?I searched the net but didn't see anything.

I got the solution to create templates Thanks to the comments.Now the only problem remaing is the following how can I make a part of code always appear when oppening a new file.More precisly I wan't this part always appear:

inclue <bits/stdc++.h>

using namespace std; int main(){ ios::sync_with_stido(false): cin.tie(nullptr);

return 0;

}

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Taha1506, history, 3 months ago, In English

Is it considered A cheating if I use another person's implemention for a data structure instead of designing one by myself?

Read more »

 
 
 
 
  • Vote: I like it
  • +36
  • Vote: I do not like it

By Taha1506, history, 3 months ago, In English

In today's contest I used (1<<k) to denote $$$2^k$$$ but.It turned out that (1<<k) won't generate long long values so I got time limit exceeded in test three.Then I decide to implement power using multiply and return both the power and the number itself but it take more amount of code and I used to spend many time debugging it.Any suggestions?

Read more »

 
 
 
 
  • Vote: I like it
  • -3
  • Vote: I do not like it

By Taha1506, history, 3 months ago, In English

Solving some problems I saw that I really need a template for modular arithmetic to avid long time spending on them. so I created it.But each time using it I had to copy paste it from the original part.Recently I saw a stream from twitch in which he just wrote segtree and the whole segment tree structure appeared.How can I do this in far manager?I searched the net but things were really complex so I decided to ask here.

Read more »

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it