Блог пользователя GlydonNeedsDedication

Автор GlydonNeedsDedication, история, 9 месяцев назад, По-английски

for the Problem 1849C

The SOLUTION I wrote, it is having some out of bounds error in the below code portion.

    s += (char)('0' ^ '1' ^ s.back());
    s = ("" + (char)('0' ^ '1' ^ s[0])) + s; // this line giving error 'out of bounds' though working fine in LOCAL
    n = s.size();

I am not able detect the exact reason.

Same purpose If I try to do like below, its working as expected

// working as expected
    s += (char)('0' ^ '1' ^ s.back());
    reverse(all(s));
    s += (char)('0' ^ '1' ^ s.back());
    reverse(all(s));
    n = s.size();

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

Автор GlydonNeedsDedication, история, 3 года назад, По-английски

As I didn't get the solution provided in the editorial of 1585D - Yet Another Sorting Problem and how it can be done with O(N)

I had come up with this logic O(NlogN):

1st-> If there is a duplicate element, we can sort the whole array with the help of those two using the 3-cycle technique so always "YES"

2nd-> if there is no duplicate present, simply take one element at a time and place that element into its perfect position (the position where it should be if it was sorted) using the 3 cycles technique.
When 2 elements are remaining and they are not sorted it means they can't be sorted as you require 3 elements to sort!


There might be better solutions available but I guess it's easy to understand and observe also.

My solution -> click here

Полный текст и комментарии »

  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится

Автор GlydonNeedsDedication, история, 3 года назад, По-английски

I saw this Solution of Problem B by maroonrk using Topological sort in contest Round #758 (Div.1 + Div. 2)
Can anybody explains the intuition please?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +9
  • Проголосовать: не нравится

Автор GlydonNeedsDedication, история, 3 года назад, По-английски

For a practice problem of bitmask in Topic Stream Mashup: Bitwise Operations
( If not opening , click HERE )
I wrote 2 solutions ( Solution1 , Solution2 )
Solution1 is accepted
But Solution2 is showing Memory Limit Exceeded even for testcase1

Can Anyone explain why this happening?

The only change between the two codes is shown here ->
main difference

Полный текст и комментарии »

  • Проголосовать: нравится
  • -5
  • Проголосовать: не нравится

Автор GlydonNeedsDedication, история, 3 года назад, По-английски

Most of the DP tagged problems that are below 1600 RATING are solvable by Greedy Approach hence not making much progress in my DP practice and DP problems that are rated above 1600 feels a bit tough even to understand sometimes. So what should I do? :( I know and solved many of the classical DP problems but am still unable to implement DP most of the time in CodeForces.

What should I do?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +24
  • Проголосовать: не нравится