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

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

I’m looking for someone around my level to do problems together, think through ideas, debug, and improve. Just want a teammate to practice and learn with.

I'm Persian so I rather someone in the Asian time zone and also need him to have discord, dm me here or on discord

scp_o96 is my discord id, Its an o not a zero

also who uses the language c++ mostly

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

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

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

Binary search does 5 operations

  • Calculate mid: 3 operations (1 subtraction, 1 division by 2, 1 addition)
  • Compare target with mid element: 1 comparison
  • Update boundary (low or high): 1 assignment

Ternary search does 9 operations

  • Calculate mid1 and mid2: 6 operations (2 subtractions, 2 divisions by 3, 2 additions/subtractions)
  • Compare target/function values at mid1 and mid2: 2 comparisons
  • Update boundaries (low, high, or both): 1 assignment

What is ternary search?

Ternary search is a type of search similar to binary search but instead of splitting the vector into 2 and checking which half the answer is in, it divides it into 3 parts and checks which third contains the answer.

So binary search is O(log₂ n) while ternary search is O(log₃ n).

But I'm here to prove ternary search is always slower.

Let's write log₃ using log₂.

(log₃ n) / (log₂ n) = (log n / log 3) / (log n / log 2)

(log n / log 3) / (log n / log 2) = (log 2) / (log 3)

(log 2) / (log 3) ≈ 0.6309297536...

So log₃ is almost 0.63 * log₂.

Since log₃ = 0.63...(infinite decimals) * log₂, we can round and conclude:

log₃ < 0.64 * log₂

Let's put it in our inequality:

9 * log₃ > 5 * log₂ -->

9 * log₂ * 0.64 > 5 * log₂

5.76 * log₂ > 5 * log₂ which is true

Since the growth ratio of log₃ to log₂ is less than 1, log₃ will increase more slowly, so ternary search, despite dividing into 3 parts, performs more operations per iteration and thus is always slower than binary search.

Also an interesting fact is that while the O of one is Log3 and the other is Log2, the log2 is faster than the log3.

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

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

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

Given a graph G, find the largest bipartite subgraph of G that contains a Hamiltonian path.

where a bipartite graph has its vertices split into two sets with edges only between sets, and a Hamiltonian path visits every vertex exactly once without vising an vertex twice or more.

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

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

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

https://mirror.codeforces.com/problemset/problem/1334/A

its a basic for loop and i have seen questions rated 800 harder than it, i know each rate has its easy and hards but i think this one is just to easy since it does not need a special algorithm either

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

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

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

I have some opponents to get my level too which are doing many questions daily but i cant see any of them in their submissions, is there a private feature or something ?

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

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

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

You are given an array of n numbers

Find the longest consecutive subarray so that The Last and First member of the sub array is Neither the Smallest or the Biggest member of That subarray (not the entire array)

for example

1 3 2 4 6 5 7

the sub array [3, 2, 4, 6, 5]

in this subarray the smallest member is 2 and the biggest member is 6, the first member is 3 which is not equal to 2 or 6, the last member 5 is not equal to 2 or 6 either so this is a valid subarray, so you cout 2 6 (the l and r of the subarray)

The goal is to find a Valid subarray

the second Goal is to find the Biggest valid subarray

the numbers are from 0 up to 1e9 and n is from from 1 up to 2*1e5

My strategy is to make a two vector of vectors, saving the numbers sorted from index 0 up to i so you can always know the smallest and biggest member of each subarray and then just do a sliding window algorithm.

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

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

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

You have an array of n numbers and an integer x, find the biggest subarray so that its Product is not dividable to x and n is up to 1e5

I also have a similar question for the biggest array so that their sum is not dividable to x

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

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

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

i just found question 1 and 2 quite simple and 3 and 4 quite difficult i found 4 much more simple than 3 but the third question of this div 3 was even easier than the last div 2's third question

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

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