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

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

So today I remembered an incident I witnessed a couple of years ago.

I was in an Algorithms and problem solving boot-camp with some Colleagues, and the unusual and unprecedented most bizarre thing I've ever seen happened.

One of my friend's C++ code printed itself on the Windows CMD!!, and it was so hilarious because this guy was so opinionated and impossible to argue with when presenting his solutions, that even his codes wanted to express how stressful that was by printing it selves on the CMD.

And since then I've been trying to find anyone on the internet who had the same issue or bug, and found nothing since then.

Is there any possible explanation for this incident ??

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

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

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

Hey, some problems that requires cumulative frequencies asks for range update and range queries.

This problem in it's simplest form can be solved using segment tree with lazy propagation.

It can also be solved using binary indexed tree, but using it here differs from using it with range update and point query, or point update and range query.

Now I read couple of articales about it, but they all give a breef explanation about direct solution only, that two BITs needed.

I still can't understand why this problem occers and how was this solution invented.

Can someone please explain this topic.

Thanks :D

Edit: This is a link to one of the explanations for this problem.

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

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

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

Hey,

For problem: Lauren And Inversions

My code pass all but two huge cases.

What is wrong with my approach ?

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

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

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

This is the problem statement.

In My solution I precalculate the sortedness between existing values and save it in global variable sum

Then I calculate the value val[i][j] where i represent the index of a position with missing value in the given sequence and j represent the index of one of the missing values in vector want,

then I find the rest of sortedness values using TSP function, I used map because the state would be too big to fit in an array.

But the solution didn't pass.

Is there any other optimizations to be considered for my implementation.

Thanks.

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

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

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

Hey all,

So the best thing to do after a contest is to read editorals for problems that I read and couldn't come up with a solution during the contest.

But I find that most editorials are hardly helpful, because all I find is a direct explanation of the solution.

What I'm saying is that it is better to explain the steps you took to reach that solution, how you thought and came up with it, like sometimes I think of a bruteforce solution and then I conclude something that reduce it to better or simpler solution.

Looking forward to reading more opinions about this.

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

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

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

Hey all,

I always felt that programming contests differ from CF To TC to ACM etc,,

Do these contests have different styles in the problems they present.

And does improving my skills in one or two of them should reflect on the others ?

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

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

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

Hey,

What is the concept behind graph problems test case generation.

How can I write a random test case generator ?

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

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

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

Hello,

I'm trying to solve the last problem in this contest.

and this is my code, my idea is to change every strongly connected component into one node because the cost of travailing between it's nodes is ZERO, this can be done by removing all bridges and then applying union find on elements of the other edges.

Then I create new adjList using elements of the removed edges "i.e bridges", the new graph will form a tree.

Then I apply DFS two times to find the longest path in a tree.

Last step is to follow the longest path and save the sum of edges on the sides of each node, take the maximum sum between the left and right sum.

Sometimes it returns TLE and sometimes RTE.

What could be the mistake, and is there a better way to solve it.

Thanks.

EDIT: now this code gets WA

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

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

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

Hey,

Are there any plugins or tools available for codeforces contest, like those for TC ??

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

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

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

Hello CF and TC people,

I installed Greed plugin following steps in this link

But I keep getting this screen when I open any problem in the arena

PS: Im using elementary os luna

Any help would be appreciated.

Thanks :D

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

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

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

Hay codeforces, Is it possible to solve standard RMQ problem using binary indexed tree with conserving LogN queries ?

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

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

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

Hello,

This is an interesting data structure problem.

It can't be solved with regular insertion and print.

Who do you think it can be solved ??

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

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

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

Hello,

As I was trying to solve ZigZag problem on topcoder the weirdest thing happend.

#include <bits/stdc++.h>
using namespace std;
class ZigZag {
public:
	int longestZigZag(vector<int> arr) {
		int dp[55], state[55];
		memset(dp, 1, sizeof dp);
		cout << dp[0] << endl;
		memset(state, 0, sizeof state);
		for (int i = 0; i < arr.size(); ++i) {
			for (int j = 0; j < i; ++j) {
				if ((j == 0 || (arr[i] - arr[j] < 0 && state[j] > 0)
						|| (arr[i] - arr[j] > 0 && state[j] < 0))
						&& dp[j] + 1 > dp[i])
					dp[i] = dp[j] + 1, state[i] = arr[i] - arr[j];
			}
		}
		return dp[arr.size() - 1];
	}
};

as I ran the given code, the cout statement gives 16843009.

I removed it and initialized every element int the first loop and it worked.

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

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

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

for this problem on spoj, Im getting WA and I don't know why !!

This is my code

Any hints ??

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

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

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

Hello,

In this blog, I would like to ask for your training experiences.

The ACM local contest will be in three month, and the regional contest is in December, and I believe I still have enough time to improve my skills.

I'm fast in reading problem statements and coding whenever I understand the problem completely. I know basics of graph theory problems, number theory, dynamic programming, and working on improving my data structure skills.

But whenever I participate in a codeforces contest, I feel there is a lot of skills I'm missing.

So it would be very kind of you to share or provide a good training schedule for the amount of time left before the coming contests.

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

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

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

hello,

for this problem, all I could come up with is to find all divisors of 'b' that are less than or equal to 't' using O(sqrt(n)) but It will get TLE for such input limits " < (1<<54)".

any hints for a better aproach ?

thanks :D

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

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

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

hey guys :D

I have this small math problem,

( a * b ) mod n = 1

Given a, n:

find the smallest value of 'b' that satisfies the equation above.

any Idea about how to find the answer better than linear time search.

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

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

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

Hey you guy's :D

Im wondering, given a number as input, what is the best way to find the smallest palindromic prime number greater than the given number.

Assume the answer fits in long long int as in c++

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

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

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

Hello,

I went through some problems that needs hashing or can be efficiently solved using hashing.

But it is still hard to understand this topic.

can any one please provide a tutorial link for me.

Thanks :D

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

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

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

Hello ,

I tried to solve this problem using subset sum algorithm and precalculation for all numbers which satisfy the given condition, But i got alot of TLE.

is there any fast subset sum algorithm better than O(n^2) ??

This is the problem :http://www.ahmed-aly.com/p.jsp?ID=172

And this is my code : Edit after AC :D

Thanks

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

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

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

For this problem on spoj: http://www.spoj.com/problems/ODDDIV/

Code Removed After AC :D

I went through the following steps to solve it: 1_ generate all primes to sqrt(1^10) to use them in prime factorization

2_ pre calculate number of divisors for numbers in range (1 — 100000)

3_ answer each query in O(n) time, I found that only perfect square numbers have odd number of divisors, so I only need to check if(fact_num[i] == k)from x to sqrt(y)

Any help to improve my time ??

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

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

Автор OmaeWaMouShenDeiru, 10 лет назад, По-английски
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

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

Hello, I would like ask to how is new rating calculated after each round ??

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

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

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

Hello codeforces community I wanna learn how to use Fread Fwrite for faster I/O.

If you have any useful example, I will be thankful :D.

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

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

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

Hello programmers,,

I read someones code a couple days earlier and i saw a piece of code using __typeof operator as a shortcut of a for loop. What is this operator and can it be used ?? Thanks :D

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

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