Can someone suggest me what are good practices to write more readable codes? Indentation, variable naming, spaces, alignment etc.. also some users who write good looking codes?

thanks,

# | User | Rating |
---|---|---|

1 | MiFaFaOvO | 3520 |

2 | tourist | 3430 |

3 | apiadu | 3351 |

4 | mnbvmar | 3332 |

5 | Benq | 3290 |

6 | LHiC | 3276 |

7 | TLE | 3270 |

8 | Radewoosh | 3251 |

9 | ecnerwala | 3241 |

10 | Um_nik | 3240 |

# | User | Contrib. |
---|---|---|

1 | antontrygubO_o | 190 |

2 | Errichto | 188 |

3 | tourist | 179 |

4 | Radewoosh | 172 |

5 | pikmike | 166 |

6 | vovuh | 165 |

7 | ko_osaga | 162 |

8 | Um_nik | 161 |

9 | rng_58 | 155 |

10 | majk | 154 |

Can someone suggest me what are good practices to write more readable codes? Indentation, variable naming, spaces, alignment etc.. also some users who write good looking codes?

thanks,

I recently saw a problem in some online judge where I was given a **tree** and was asked the value of `Σ f(u, v) for all pair of u, v`

where f is some function that takes two nodes u, v of a graph. for example f(u, v) can be any of these.

```
1) f(u, v) = distance between u, v in a weighted tree.
2) If every nodes have number written, f(u, v) can be median / mode / average/ sum of all numbers in path from u to v.
3) if every nodes have colors assigned f(u, v) can be number of distinct colors between path from u to v.
```

Any Ideas how to solve these kinds of problems?

For any three integers is N / (x * y) same as N / x / y?

I tried to check for many random values, It comes out to be same. Is it true for any 3 integers N, x, y. How to prove it. Sorry if the question is silly.

Thanks!

```
Given an Array A of n elements, (n < 200000), At each step I can transform whole array such that for every i <= 0 < n, A[i] = A[i - 1] xor A[i + 1]. Is it possible to convert whole array to 000....0 (all zeros) after infinite steps. for example if A = [ 0, 1, 0, 0, 0, 1, 0 ],
```

```
Initial: A = [ 0, 1, 0, 0, 0, 1, 0 ]
Step 1 : A = [ 1, 0, 1, 0, 1, 0, 1 ]
Step 2 : A = [ 0, 0, 0, 0, 0, 0, 0 ]
```

So A can be transferred to zeros after 2 steps.

```
PS. Consider A[-1] = A[n] = 0, always
```

I would be highly thankful if someone helps me to solve this task. I saw this problem few days back, will post its link if I found it.

Can someone help me how to solve this problem. Link Thanks.

Given N points in one set(S1) and M points in another set(S2), Choose some edges between points from Set S1 to set S2 such that sum of edges(distances) is minimum and every vertex is chosen atleast once.

Can someone help me solving this problem. Thanks!

Given a function that generates random natural number in range [1, 100], How can I verify if it is truly generating random numbers?

Thanks!

I was learning suffix array. I want to know what is the need of n*(log n) suffix array construction, are there problems in which n*(log^2n) construction not sufficient. If so, Can someone please provide links to problems.

Thanks!

**My views**: I find USACO Contest problemsets very intersting. **Reason**: Short and interesting problem statements, nice editorial with nice readable codes.

```
Which problemset do you find most interesting/challenging?
```

```
An ordered triple (a, b, c) is called a triangle triple if a, b, c are positive integers such that there is a triangle with side lengths a, b, c and a positive area.
find number of ordered triplet (a, b, c) such that a <= A, b <= B and c <= C
Input: A, B, C (all between 1 to 10^9)
Output: Number of triplets Mod 10^9 + 7
```

Problem: [Link] Can someone please help me solving this problem?

```
Given a 2D matrix of size nxm (n, m <= 400), Calculate maximum submatrix such that all of its elements are distinct? [maximum submatrix is submatrix whose area is maximum]
```

I saw this problem on codeforces, but now I am not able to find it. solution approach or problem links are welcome:)

I am looking for some nice implementation of Max-flow & Maximum Bipartite Matching problems, With worst and average case time complexity of Algorithms. Also I want some suggestion about how to start solving problems of these categories.Till now I have solved problem using implementation of Algorithms as black box, which is not good in longer run. So I request CF community to suggest me some good ways to understand implementation and complexities of these algorithms.

Thanks !

Can anyone help me with this problem:

```
Problem: Number of Solution of equation x_1 + x_2 + x_3 + ... x_k = N
for all i: x_i>=0 and x_i<=x_(i+1) constraints:[N<= 10^9 k<=10]
```

[basically non-decreasing solutions]

I am solving LCS problem from spoj, which is

`input: 2 strings of length atmax 250000 characters (S1 & S2)`

`Output: length of the longest common substring of them.`

my approach:

```
n1 = S1.length() , n2 = S2.length();
S = S1 + '#' + S2;
build Suffix_Array (SA[]) and LCP_Array (LCP[]) of string S;
Ans = 0;
for(i = 1 to n1+n2 ):
if( (SA[i-1] < n1 && SA[i] > n1) or (SA[i-1] > n1 && SA[i] < n1))
if(LCP[i] > Ans)
Ans = LCP[i];
return Ans;
```

Which is giving TLE as time limit for the problem is too strict (0.294s). Can someone please help me with this. `Thanks !`

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jan/18/2020 16:06:11 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|