Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems. ×

arham_doshi's blog

By arham_doshi, history, 9 days ago, ,

I got bored with solving and wanted to do something which is related to cp and also very fun so i decided to write this tutorial.bare me for my bad English .

trick

explanation
code

explanation
code

explanation
code

explanation
code

explanation
code

explanation
code

explanation
code

explanation
code

explanation
code

explanation
code

explanation
code

explanation
code

explanation
code

explanation
code

explanation
code

Explanation
code

Explanation
code

Explanation
code

19) Planet queries I

explanation
code

Hope this is helpfull to you . I will try to add more as I solve furthure.

• +77

 » 9 days ago, # |   0 Auto comment: topic has been updated by arham_doshi (previous revision, new revision, compare).
 » 9 days ago, # |   +1 Problem links?
•  » » 9 days ago, # ^ |   +5 https://cses.fi/problemset/First register to create an account then you will be able to submit your codes.
•  » » » 9 days ago, # ^ |   0 Thanks :)
 » 9 days ago, # |   +5 Nice initiative.
 » 9 days ago, # |   +5 Very nice and helpful.
 » 9 days ago, # |   +5 Thanks arham_doshi
 » 9 days ago, # |   +5 all hail ......editorialist arham_doshi
 » 9 days ago, # |   +9 This may also help. https://github.com/ankitpriyarup/CSES_ProblemSet_Solution
 » 8 days ago, # |   0 Hi, thanks for the editorials. I am unable to understand the problem $High$ $Scores$. It says we can use a tunnel several times, that means if there is an edge with positive weight can't we use it several times(infinite times i.e. $a$ -> $b$ then $b$ -> $a$ ... ) and our answer will be -1? and i think in the editorial you meant Bellman ford instead of Floyd Warshall.
•  » » 8 days ago, # ^ |   +1 Yes, we can use it hence you have to print -1 as said in the problem statement.
•  » » » 8 days ago, # ^ |   +1 If that is the case why our answer is 5 for sample? We can use the edge with positive weight from 1 and use it infinite times and our answer will be -1. Sorry if I misunderstood you:(
•  » » » » 8 days ago, # ^ |   +1 All tunnels are one-way tunnels...means it's a directed graph.
•  » » » » » 8 days ago, # ^ |   +1 Oops. Sorry my bad. :(
•  » » » » 8 days ago, # ^ |   0 yeah may be i got confused sed between bellman ford and floyd warshal.talking about sample it is a directed edge so after going from a to b you canot go back. " the tunnel starts at room a, ends at room b "
 » 8 days ago, # |   +29 how to solve grid problems Here is an additional trick for grid problems. Specifically for problems where the input is some kind of maze with # for "blocked" cells and . for "free" cells. I like the approach of using the dx and dy arrays but the possible function feels clunky to me in some problems.Instead I put a "frame" made out of # around the whole grid. That is: when the input is ..#..#. .#..#.. #.#..#. .#...#. instead I consider the input ######### #..#..#.# #.#..#..# ##.#..#.# #.#...#.# ######### It is really easy to implement. Initially fill the whole grid with #, then read the input.
•  » » 8 days ago, # ^ | ← Rev. 2 →   0 Nice one, i like it. I use possible at many places like when when solveing a dp probelm
 » 8 days ago, # |   0 Auto comment: topic has been updated by arham_doshi (previous revision, new revision, compare).
 » 8 days ago, # |   0 Auto comment: topic has been updated by arham_doshi (previous revision, new revision, compare).
 » 8 days ago, # |   -8 I am weak at graph. I think, it will help me so much..Thank you so much Sir !!!
 » 3 days ago, # | ← Rev. 2 →   0 I'm having trouble with Building Roads problem. For some reason, I am getting TLE for test cases 6-11, although my solution is similar in idea to ones that have been accepted. How can I change my code so I don't get TLE? #include #include using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef long double ld; typedef unsigned int ui; typedef unsigned long ul; typedef pair pi; typedef pair pl; typedef vector vi; typedef vector vl; typedef vector vpi; typedef vector vpl; typedef priority_queue pq; typedef priority_queue,greater> pqg; typedef tree,rb_tree_tag,tree_order_statistics_node_update> indexed_set; #define mp make_pair #define pb push_back #define f first #define s second #define lb lower_bound #define ub upper_bound void dfs(int start, vector adj, vector& visited){ if(visited[start]) return; visited[start]=true; for(auto u:adj[start]) dfs(u,adj,visited); } int main() { ios::sync_with_stdio(0); cin.tie(0); int n,m; cin>>n>>m; vector adj(n+1,vi()); for(int i=0; i>a>>b; adj[a].pb(b); adj[b].pb(a); } vector visited(n+1,false); vi add; for(int i=1; i<=n; i++){ if(!visited[i]){ dfs(i,adj, visited); add.pb(i); } } cout<1){ for(int i=1; i
 » 3 days ago, # | ← Rev. 2 →   +18 I'm currently making Video editorials for tree section of CSES. Interested people can check : CSES (DP ON) TREE ALGORITHMSI'm hoping to finish it in around a week, will be happy to know if people find it helpful :)UPD : added first 5, do share suggestions if any.
•  » » 3 days ago, # ^ |   +5 Thank You so much, it will be very helpful.
•  » » » 2 days ago, # ^ |   0 Do share suggestions/feedback if any :)