Actually the tree combination calculation is so complicated to explain in text.

I am thinking of a better way to explain it to you.

Will reply to you in a day.

Active In

Competitive Programming

International Olympiad in Informatics

Web Development

Deep Learning

Machine Learning

Artificial Intelligence

Bitcoin and Blockchain

Algorithms and Data Structures

International Mathematics Olympiad

Featured Contributions

reply in this discussion

Actually the tree combination calculation is so complicated to explain in text.

I am thinking of a better way to explain it to you.

Will reply to you in a day.

Read more… (31 words)

reply in this discussion

There is a better approach than mine, but I invented a different one so thought of sharing.

#include<iostream>#include<bits/stdc++.h>using namespace std;#define MAX 10000005int n,k;

Read more… (159 words)

reply in this discussion

Struggled a lot with TLEs until I declared maps as local variables. Don't know why.

Anyways here's my solution:

#include<iostream>#include<cmath>#include<vector>#include<utility>#include<queue>#include<algorithm>#include<climits>#include<unordered_map>#include<cstring>#include<stack>#include<set>using namespace std;int sub[1000000];set< pair<int,int> >adj[200000];int k;int ans=1e9;unordered_map<int,int>m,temp_map;

Read more… (19 words)

reply in this discussion

Read more… (5 words)

reply in this discussion

Here is my code:

#include <bits/stdc++.h>#define MOD 1000000007using namespace std;typedef vector<vector<long long>> matrix;matrix mul(matrix a,matrix b){int r=a.size();int c=b[0].size();int k=b.size();

Read more… (72 words)

reply in this discussion

Yes, you are right both are slightly different approaches.

Although we are trying to do the same thing i.e. trying to find the best incoming and outgoing wormhole for each contest and finding which takes minimum time.

In the approach for which Keshav has given hints, we sort contests by starting time and then we can compute best incoming wormhole in linear time for each contest.

Similarly to compute best outgoing wormhole we sort the contests by ending time.

Read more… (79 words)

reply in this discussion

I had studied Dijkstra lot of times earlier but couldn't understand how it works and why it doesn't work with negative weights. But understanding proof of correctness has given a lot of understanding and intuition. I don't understand why very few people stress on proofs.

Read more… (45 words)

reply in this discussion

reply in this discussion

Fine tuned my DP concepts as hell! Thanks a lot for this awesome Quiz.

Read more… (14 words)

reply in this discussion

Here is a very good resource for learning Dynamic Programming. It is Google Codelab's own tutorial for preperation of Google Kickstart

Read more… (21 words)