Comments
On piloopCodeforces Round #119, 7 days ago
+18

That was not me, that was homo_sapiens.

On Aksenov239Codeforces Round #118, 13 days ago
0
2 0 2 2 2
| | | | |
2 4 2 4 2

Fourth 2 won’t break the scales.

On Aksenov239Codeforces Round #118, 13 days ago
+37

My solution, which passes system tests, fails this test.

+/-1 in general doesn’t change odd/even for B%(A+1), if A is even. If B%(A+1) = 0, then (B-1)%(A+1) = A – oddness doesn’t change.

You don’t have to lose first two games. If you win the third game, you will have a bag big enough to fit any presents from first two days, should you win any.

(double post)

Let’s say the larger number is B, the smaller one is A. If A is odd, the case is pretty simple – after each turn B % 2 changes, so we win if and only if B%2 = 0.

If A is even, we win if B % (A+1) is even. To prove it we need to prove that each winning state has a move to a losing state, and that any move from the losing state only goes to a winning state.

If B % (A+1) is even, we can always make it odd by subtracting one, if B % (A+1) is not zero, or by subtracting A, if it is zero. That proves that from every winning state there’s a move into a losing state.

If B % (A+1) is odd, any turn will make it odd. This can be proven by induction: If you subtract A^0=1, B % (A+1) will obviously become even. Let’s say we have proven that subtracting A^k changes oddness. Since subtracting A^k * (A+1) obviously doesn’t change oddness (since it is divisible by A+1), subtracting A^(k+1) = A^k * (A+1) — A^k does change it. That proves that from any losing state you can only move to a winning state.

0
"The book, Game of thrones is very good. Read it."

That is very true :)

On YouTubeHeroesNotarized screenshot, 4 months ago
+1
In the case above stand is a noun, not a verb.
On paladin8Z Algorithm, 6 months ago
0
one can  transform Z<->prefix in O(n)

How?
I use Qt Creator too. Built-in fake vim mode is very handy, and debugger is quite good.

On ShuaibTiming for CF Round 94, 6 months ago
+22
For my timezone that is the best time possible :)
On RipattiCodeforces Beta Round #93, 6 months ago
+3
Suffix Array has complexity NlogN

That's improper suffix array. Proper Suffix Array is linear :)

On SammarizeCodeforces Beta Round 79, 9 months ago
+5
Also, Visual Studio handles %lld correctly. So if you want to submit solution which uses %lld, you can just choose MSVC compiler instead of GNU one.

On EgorGoogle CodeJam World Finals, 10 months ago
0
Thanks. Now it makes sense :)

On EgorGoogle CodeJam World Finals, 10 months ago
0
I still don't get how can one achieve N log N runtime. Whatever way of solving this problem I come up with, it requires at least N^2 of operations.
Can someone elaborate more on the way to improve runtime?

On amirali1374Unknown Language Round #3, 10 months ago
+9
sudo apt-get install pike7.8
from this perspective linux users have had a huge advantage :) I had my machine set up in two minutes after contest started.

Thanks for the contest. I love such kind of contests (short period of time, lots of reasonably easy problems). Also, I loved to learn a new language, which is similar to the languages I know, though have a very nice functional influence. However, some more obscure language would be also fun :)

On kphmdforeach(item,sets) with g++, 10 months ago
+10
Do people enjoy living in the past? Why do you need a macro for something which has been part of the language for a while now?

int my_array[5] = {1, 2, 3, 4, 5};
for (int &x: my_array) {
    x *= 2;
}


On nealTesting $\LaTeX$, 11 months ago
+5
My bad :o(
I also have just "Testing" in the title then.
On nealTesting $\LaTeX$, 11 months ago
0
This is what I see in the HTML code:
<div class="from-renderer">Testing <img align="middle" class="tex-formula" src="http://codeforces.ru/renderer/a0188aa9bb752581e1f8018162e402bcc76b4f66.png" /></div>
It's unlikely that browser fails to show PNG picture. May be the server returns different HTML depending on some settings, or something like that.

On nealTesting $\LaTeX$, 11 months ago
+5
Chrome 12.0.742.91, Ubuntu 10.10, see Testing  in the title.
Yes, I just agreed :)

And this is exactly why IT giants look for such people and organize such events. If person is successfull in programming competitions, he is smart. That means that hiring him today is good investment in future, since there's some level of confidence that this particular person will become a good engineer after developing required skills during first year of employnment or so.

Well, even though I personally agree with Ivan, that ideally they should have stopped after the first paragraph, I've got to confess that what Yandex says is way better than what happens on ICPC or any other competition opening ceremony, when lots of people tell how proud they are to be in the same room with you and how proud they are to sponsor/organize/do whatever they do in this prestigious event (while, of course, they are not, and most of them don't really care -- most of them don't even understand what this competition is).
Yandex is honest with you, and I kind of enjoy it :)

Also I cannot help but mention one more time: solving problem doesn't make you a good coder. It's good up to certain extent, but other that that it just way of having fun (and of end up receiving prestigious achievement), and has nothing to do with developing any usefull skills.

On ahmed_alyCodeforces vs. TopCoder, 12 months ago
+40

Recent topcoder failure was not because of number of participants. TopCoder can handle 2200 participants pretty easily I believe.

> I like Codeforces hacking more than TopCoder challenges.
I definitely prefer TopCoder challenges rather than Codeforces hacks.

 

On Alex_KPRCodeforces Beta Round #69, 13 months ago
+9

Потому что в раздельном контесте можно решить четыре задачи, а в общем только две. Первое делает человека более счастливым :о)

Писать сложный контест и решать в нем только А и В -- это не очень круто тоже.

 

I totally prefer such statements though.

There was a contest where each statement was two-five lines long, and I loved it.

 

And also I have never seen an interesting background story in the problem statement. Usually they are pretty rediculous. And I'm not into that kind of humor which is usually used in the problem statements.

So if someones made a contest with no stories whatsoever, I would be very happy :)

 

On Alex_KPRCodeforces Beta Round #69, 13 months ago
+6

Snowy, Hex

Anka, Chapay, Cleo

Troll, Dracul

gives 89, 5

On TachyonManthan 2011, 14 months ago
0

My bad. I meant RRRRRL

You can see on which test your solution failed. Click on the submission ID on the status page.

On TachyonManthan 2011, 14 months ago
+8
Besides the fact that problem A should have had better pretests, I would also swap problem C and D.
Problems themselves are very good overall. I pretty much enjoyed solving all of them.
On TachyonManthan 2011, 14 months ago
+6
LLLLLR for instance.
This is one on which I failed, and then I saw several people doing the same mistake.
On TachyonManthan 2011, 14 months ago
+28
I so hate when problem A has tricky cases.
Hope sooner or later problem writers will realize that this is not cool.

Some people earned 3000 points by hacking problem A. It is more than average person could achieve by solving C and D together. I don't know what it proves.

I agree with al13n. This comparator seems not to be transitive.

If cross product of A and B > 0 and cross product of B and C > 0, it does not necessarily mean that cross product of A and C > 0, that said for your comparator A>B && B>C doesn't guarantee that A > C, which is required for std::sort

On cauchykMatrix Exponentiation, 15 months ago
+4

If N is very large (10^100 for example), and R is reasonably small (100 for instance), you can create (R+1)x(R+1) matrix A, which has ones on the main diagonal and on the diagonal above main, than compute v(A^N), where v is [1,0,0,0,...,0]. Last element of resulting vector will be the answer.

I believe this is what you were looking for

 

On nevidomyCodeforces Beta Round #53, 16 months ago
0
What is so special about this test?
On cauchykFacebook Hacker Cup 1A, 16 months ago
0

Yes, good point. Seems like it will work.

 

 

On cauchykFacebook Hacker Cup 1A, 16 months ago
0

Marked it as bold for you :o)

 

if first K elements are non-decreasing sequence and last N-K+1 elements are non-increasing sequence

On cauchykFacebook Hacker Cup 1A, 16 months ago
+5

How does it handle case when left part is much longer than the right part?

1 2 3 4 5 6 7 8 9 10 3 for instance?

On cauchykFacebook Hacker Cup 1A, 16 months ago
+5

First of all,

a1 * ( a2 - 1 ) * ( a32 )

During the contest, believing that two sequences which elements are the same, but indices are different, are different (which is wrong) I coded the following solution:

Meaning of i and j is the same as yours,

k is sum of lengths of left and right parts

z (z is from 0 to 1) is whether we ever moved right pointer or not. Since when left and right pointer meet, I cound solution if and only if either left pointer points to number strictly greater than the one right pointer points to, or if right pointer was never moved.

It gives answer=19 instead of 17 on the fourth sample, since it counts some 1 2 and 1 twice.

Have no idea how to handle equal sequences yet.

On cauchykFacebook Hacker Cup 1A, 16 months ago
0

I checked my input file for that problem, and it contained only test cases where there's either unique answer or there's no answer. So likely both of you passed.

On cauchykFacebook Hacker Cup 1A, 16 months ago
+1

(wrong place)

On cauchykFacebook Hacker Cup 1A, 16 months ago
+3

Fix what lamps are switched in the first row (2^m), iterate over all the rows starting from second (n), for each row for each lamp (m) switch it if and only if lamp above is off.

Complexity is 2^m*m*n.

On cauchykFacebook Hacker Cup 1A, 16 months ago
0

I have compared my answer to the answer of the person who used gauss, and it was the same.

I used 2^n*n*m solution.

May be it can be proven that answer is alweys unique. Or facebook is lame enough to prepare only tests which have unique solution.

On cauchykFacebook Hacker Cup 1A, 16 months ago
0

Even though it did appear to me that gauss works, I've chosen to do 2^n*n*m anyway. Since it seems to be much easier..

Also interedted in how to solve problem B.

 

I wonder if it was translated by the girl who used to translate problem statements at the very beginning of by some other person.
I can easily understand problem statement, though I might understand what is the reason why so many people are confused. Several sentences are very 'russian'-spoiled. Like

"the positive integers i such that for at least one j (1 ≤ j ≤ n) is true both."

Instead of "is true both" I'd say "the following holds" or "the following statements are true". I'm not sure if "is true both" is grammatically correct at all.

"and in one place can stand exactly one volume."

I believe verb cannot be placed before noun. Correct would be "and only one volume can occupy one place".

I can be wrong, my English knowledge is not so awesome. I'm just guessing..


Mike: just to make sure you know: this topic appears on Russian when one is watching the site in English interface.

 

On RADCodeforces Beta Round #23, 22 months ago
0
Потому что Input.txt и Output.txt?
On swcaiRandom thoughts on codeforces, 23 months ago
+26
I like your logic "I don't know Python, forbid it" :o)
By the same logic Pascal definitely should be forbidden, because
1) It's syntax is completely different from C++-style languages and tough for understanding
2) It's used (and, I believe, known) by much fewer number of programmers over the world than Python

Even if I know 10 languages, it doesn't mean that I can effectively solve problems on all of them.
If you don't want to improve your skills by learning at least basics of those languages, it is definitely your problem, and, moreover, it is bad for you in first place. Let me explain why.
First of all, lets exclude PHP from this discussion, as it is C++-like language, and if you understand C++, you should understand PHP code as well.

If you don't know Haskell (or any functional language at all), then you don't understand functional paradigm, and without understanding it I don't think you will succeed in new era of programming languages, when list comprehensive and lambda functions are becoming available in more and more languages (even new version of C++ contains lambda functions).

If you don't know Python/Perl/Ruby/ some other scripting language, then basically you know, how are you going to solve some practical problems when you need to let's say to download 20 pages from web and extract some data, or to do some stuff with files on your machine.

In other words, I don't say that every person must know all the languages and feel comfortable coding in all of them. But understanding of basics of functional programming, as well as knowing at least one scripting language, is reasonable, and it makes your concern meaningless
On RADCodeforces Beta Round #18 (Div. 2), 23 months ago
0

In .NET 4.0:

using System.Numerics;

BigInteger a;

Then you can use it as a regular integer number. All the operators are overloaded, so you can easily do something like that:

BigInteger a = BigInteger.Parse( Console.ReadLine( ) );
BigInteger b = BigInteger.Parse( Console.ReadLine( ) );
BigInteger c = a + b;

But AFAIR this server doesn't support .NET 4.0, so anyway you will need to implement big integers by hands if you want to solve that problem using C#.

On brainailCodeforces Beta Round #17, 23 months ago
+24

Decide = принять решение
Solve = решить (задачу)

On simp1etonNew User, 23 months ago
+13
Answer for first question: scanf and printf are from stdio.h, not iostream.h

Second: %lld doesn't work in MinGW. Either use %I64d instead, or choose Visual C++ instead of MinGW when you submit.
On adamaxCodeforces FAQ, 2 years ago
+1
Most likely for Visual C++ both of them work fine.
For GNU only I64d.
On adamaxCodeforces FAQ, 2 years ago
0
Actually, "%lld" works perfectly fine, if you submit using "Visual C++" instead of "GNU C++", and I believe is should be mentioned.
So F# is .NET language, isn't it?
Does it use Mono or Miscrosoft Framework?
+1
Both problem are addressed in Visual Studio 2005 and later.
You can download Visual C++ 2005 express (and any later version) from Microsoft site for free. I use 2010 version, which I really like.
Regarding "create of project" issue - it depends on preferences. I have only one project for all the competitions I participate in. When I need to switch from one problem to another, I delete old one from the project, and add a new one (Ctrl+Shift+A, doesn't work with Miranda-IM running :o)). If I need then to return to previous one, I always can add it back (Alt+Shift+A)

But more often I use Far Manager to code problems on C++.

For Java I hate all the IDEs existing, so I use Far Manager as well. For sure, I don't have autocomplete, and will not even try to convince anybody, that I have any benefits from using Far. I'm pretty sure that using any IDE will make solving problems on Java faster, though I just don't like them :o) I hate IntellijIdea for being so different from Visual C++, I hate both Eclipse and NetBeans for being very slow.

For C#, which is my primary language now for all the competitions which support .NET 3.5+ I use Visual Studio 2010. As I said, it is pretty much awesome.
Sometimes, but not very often, I use Far Manager to code problems on C# as well (for instance, on my minibook visual studio behaves slowly, so Far Manager is more convenient if I want to code something and my minibook is the only machine available at the moment).
This is also the IDE (and the language) I work with on my job, so it makes it easier when you use the same tool for all the purposes.
On meretCodeforces Beta Round #11, 2 years ago
0
Codeforces uses MinGW, which DOES support long long, but DOES NOT support %lld. %I64d should be used instead. Or you can simply submit using MSVC compiler, in most cases it will be fine.
I've been to China twice - in Shanghai in 2005 and, like the author, in Harbin in 2010.

Before Shanghai I'd never been to USA, so I'd never seen any skyscrapers, and seeing so many of them were exciting. What was more exciting? To see urban district in a couple of blocks from all these skyscrapers.
But the most memorable event was shopping, anyway :o) We were in some nice shopping center with one of the ICPC volunteers, who spoke both English and Chinese. So, having poor skills in English, we were able to communicate with people in shopping center, and like the author, we were able to drop 60-80% of the initial price pretty much often.

On my trip to Harbin I didn't go to any shopping centers, as now I find it kind of pointless :o) Because usually in ends up with a lot of stuff you don't really need (or a lot of gifts people whom you are going to present them do not really need :o)). So I concentrated on walking in the city center, visiting all the exhibitions offered by host and actually, as now I'm outside of my home country, to talk to my friends, whom I met first time after a half an year
Basically, the impression is pretty much the same - a lot of skyscrapers and other nice buildings mixed up with ugly urban houses. This is kind of funny :o)

On hadiMonty Hall Problem, 2 years ago
0
Actually in Monty Hall problem solution is not most interesting part.
Most interesting part is to find random person (friend, family member), and try to convince him that answer is 2/3 and not 1/2 :o) Sometimes you can spend a whole day arguing without no success :o)
On hadiMonty Hall Problem, 2 years ago
0
M-m-m, it is also explained in wikipedia.
Correct problem statement from wiki:

Suppose you’re on a game show and you’re given the choice of three doors. Behind one door is a car; behind the others, goats. The car and the goats were placed randomly behind the doors before the show. The rules of the game show are as follows: After you have chosen a door, the door remains closed for the time being. The game show host, Monty Hall, who knows what is behind the doors, now has to open one of the two remaining doors, and the door he opens must have a goat behind it. If both remaining doors have goats behind them, he chooses one randomly. After Monty Hall opens a door with a goat, he will ask you to decide whether you want to stay with your first choice or to switch to the last remaining door. Imagine that you chose Door 1 and the host opens Door 3, which has a goat. He then asks you “Do you want to switch to Door Number 2?” Is it to your advantage to change your choice?
On hadiMonty Hall Problem, 2 years ago
0
In this problem answer is "No, there's no advantage" actually :o)
Because it is not Monty Hall problem. In Monty Hall problem participant knows that host will open another door with goat behind it and offer to change the door BEFORE he opens the door .
Without this knowledge you cannot be sure that host didn't open the door only because you've already chosen the door with the car just to confuse you and force you to change your mind.
+1
Ok, just to clarify:
With the probability of 10% diamonds were not hidden in any of chairs
With the probability of 90% diamonds were hidden in randomly chosen chair.
After that 11 of them were cut off and none of these 11 contained diamonds.

+1
No, the answer is not 90%
+1
No. It would be one, if diamonds were hidden for sure. But they were hidden only with probability 90%, which means that initially with probability 10% diamonds were not in one of the chairs. As a result, if we opened 11 chairs and didn't find diamonds in any of them, they are not for sure in the 12th chair. The question is: what is the probability that they are in 12th chair, if they were not found in first 11 chairs.