aditya_sheth's blog

By aditya_sheth, history, 3 years ago, In English

I am not able to share the virtual camera of OBS on zoom. How to fix this issue? I tried leaving and re-entering zoom, but that's not working.

UPD : I am using Macbook Air M1,2020

Full text and comments »

  • Vote: I like it
  • +123
  • Vote: I do not like it

By aditya_sheth, history, 4 years ago, In English

The problem asks to check if it is possible to rotate a square(of side length R*sqrt(2) in the problem) with fixed center(origin on 2-D plane) such that two points p1(x,y) and p2(x,y) lies on the border of square.

I have coded a solution using floating point operations, but it is failing on test #10.

It would be great help if anyone can help with a method using integer operations.

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

By aditya_sheth, history, 4 years ago, In English

Can someone please help me solve this problem. I came up with the following observations:

1) the first bit of the binary number should be 1.

2) we can think of each binary prefix(modulo n) as a node of the graph. So finally we need to find a hamiltonian cycle starting at 0 and ending at 0 where each node has an outgoing edge to the nodes (2*node)%n and (2*node+1)%n.

I am unable to progress further. Any help/hint will be really helpful.

Full text and comments »

  • Vote: I like it
  • +15
  • Vote: I do not like it

By aditya_sheth, history, 4 years ago, In English

Brute force solution:

vector<long long> bruteforce_solve
{
	vector<long long> ans;
	for(int j=2;j<=n;j++){
		long long sum=0;
		for(int i=1;i<j;i++)
		{
			//LCA(i,j) returns the least common ancestor of 2 nodes in tree.
			sum+=V[LCA(i,j)];	
			//V[LCA(i,j)] is the value written on node LCA
		}
		ans.push_back(sum);
	}
	return ans;
}

Problem Link

Full text and comments »

  • Vote: I like it
  • -9
  • Vote: I do not like it

By aditya_sheth, history, 4 years ago, In English

There are two integer points A and B in the 2-D plane. We need to find another point C satisfying the following conditions:

  1. C has to be different from A and B.

  2. There is no integer coordinate point on the line segment AC other than its endpoints.

  3. There is no integer coordinate point on the line segment BC other than its endpoints.

  4. Triangle ABC must have a positive area.

  5. There is no integer coordinate point strictly inside ABC.

Constraints:

1.|Ax| <= 1e9, |Ay| <= 1e9, |Bx| <= 1e9, |By| <= 1e9.

2.Cx and Cy must be within [-1e14, 1e14].

Problem link: problem D

Full text and comments »

  • Vote: I like it
  • +40
  • Vote: I do not like it

By aditya_sheth, history, 5 years ago, In English

A sequence of integer numbers a0, a1, . . . , an, . . . , is called the Fibonacci sequence modulo r if a0 = 0, a1 = 1, and ai = (ai−2 + ai−1) mod r for all i ≥ 2. A number p > 0 is called the period of the sequence, if there is some i0, such that for all i ≥ i0 the equation ai = ai+p is satisfied. The sequence is called periodic if it has a period. Clearly, if the sequence is periodic, it has the smallest period. Given r you have to find whether the sequence Fr is periodic, and if it is what is its smallest period. Constraints: 2 <= r <= 2*10^9

Link to the problem: Problem E.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By aditya_sheth, history, 5 years ago, In English

Can someone tell how should I learn string-processing algorithms? I currently know only z-function. Where to start learning suffix-array, suffix-tree, suffix-automaton and also in what order. Also is there a good collection of question related to this topic.

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it

By aditya_sheth, history, 5 years ago, In English

Problem. I checked various solutions. I could see DSU and Dynamic programming in most of them. Any hint or full solution would be helpful.

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it