Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

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

1 | tourist | 3496 |

2 | Um_nik | 3337 |

3 | Petr | 3298 |

4 | W4yneb0t | 3218 |

5 | Radewoosh | 3216 |

6 | OO0OOO00O0OOO0O0…O | 3188 |

7 | Syloviaely | 3168 |

8 | izrak | 3109 |

9 | anta | 3106 |

10 | fateice | 3099 |

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

1 | tourist | 184 |

2 | rng_58 | 170 |

3 | csacademy | 164 |

4 | Petr | 158 |

5 | Swistakk | 154 |

6 | lewin | 149 |

7 | Errichto | 146 |

7 | matthew99 | 146 |

9 | adamant | 141 |

10 | Zlobober | 140 |

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial of Educational Codeforces Round 30

↑

↓

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/25/2018 20:29:05 (d1).

Desktop version, switch to mobile version.

User lists

Name |
---|

In problem E, first I solved it using segment tree after iterating in two loops but I got TLE.

Then I replaced the segment tree with a liner search and I got ACC. How did that happen?

This is my first submission (31286366) which had TLE. My second submission (31286415) which passed.

F — good demonstration of overkill in using suffix array.

It is most powerful suffix structure, but anyway it needs additional lcp array, prefix sums array, stack...

Suffix automaton is better here, bcs its need only... one array cnt[]!

GL, kids.

Edit: Please ignore!

can someone please explain me E ! I didn't understand how to keep all the three maximum possible at a time. if we want to maximize the first one we can (just give 2 to smallest and rest with 1) but this is not the case here !

please help me !

The first two numbers are fixed, when you do these two loops. You just have to choose the third number maximum possible.

Can somebody share the implementation of the solution given for 873B and explain "That leads to a solution: for each value of balance maintain the minimum i where this balance is obtained (let it be called minIndex), and for each index i in the string update answer with i - minIndex(balance(i))"?

input() d={0:-1} a=b=0 for i,c in enumerate(input()): b+=2*int(c)-1 d[b]=x=d.get(b,i) a=max(a,i-x)

## print(a)

a is used to get maximum length and initialize with 0 ------------------------------------------- b+=2*int(c)-1,here int(c) equals 0 or 1,it's like cnt1-cnt0,to calculate balance[i] d[b]=x=d.get(b,i),the d is dictionary to record the minIndex,when d.get(balance[i])is None, meaning that it's not recorded yet,so d[b]=i;when d[b] is not None,meaning that it' match the balance condition,we get it as x for calculate the length i-x, just the i -minIndex; a is used to get the max length among loop,a initialize with 0;