Search


To get FREE & exclusive emails insert your email-id here

email id:



Showing posts with label computer. Show all posts
Showing posts with label computer. Show all posts

Tuesday, January 25, 2011

INOI 2011 Solutions

[Update on Jan 17, 2013: Some readers are reporting that the second solution is wrong. I cannot verify the same, but to be safe discretion is advised.]

Here are my solutions for the two INOI 2011 questions... (Indian National Olympiad in Informatics conducted by IARCS Indian Association for Research in Computing Science for Google's search :P)

The first question was about how many right angled triangles are possible with the given set of points and with sides parallel to x and y axes.

Arrays required: a 2*N array (xy[2][N])to store the coordinates. Two 10^4 long arrays (X[10000] and Y[10000] to store the number of times an x-coordinate and y-coordinate appears.
Input: Go into the loop. Get the coordinate and store it in the first array. Add 1 to X[x-coordinate], 1 to Y[y-coordinate]
The trick: Now, for every given point just multiply (X[x]-1) and (Y[y]-1)
This works because if you think of the points really as it is plotted in a graph, you'll see that for one point as the vertex with the adjacent sides perpendicular, there are as many triangles possible as the product of the remaining points left horizontal to it, and remaining points left vertical to it.
Add this for all points and do that %10000

The second question involving dynamic programming needs a solution to be constructed from one of the problems already discussed in online contest archive.
We store the marks in the array marks[N]
Now the best score at marks[0] is the same.
from marks[1] onwards, the best score is the maximum of (marks[1] alone),(best[i-1]+marks[1]),(best[i-1] dropping marks[i])
In the last case, when we drop marks[i], we must add one mark which we previously dropped to get the best mark.
Now, the trick in this is to store a best negative mark value for every i-1 so that if i is negative too, we can find dropping which is better. (where, by best negative, I mean the one closest to zero.. Because the one farthest from zero needs to be dropped.)
so we compare the best negative and marks[i] (obviously when marks[i] is negative) and keeps the one closest to zero, drops the other...

we must keep the count of K that is left. And we must also remember to restore K to maximum when we can best [i-1] is the same as marks[i] and they're both negative (or zero).

Both of the questions were particularly easy, if you thought like me. All the best for your results.

Sunday, January 17, 2010

Get Out of Full Screen Mode in Command Prompt and related windows

If you ever worked in command prompt and switched to full screen just to know how it looks, you will know how difficult it is to get back.

If every command prompt or similar windows are automatically running in full screen, you must have set the defaults to full screen.
If you set the default of every command prompt window to be full screen you can change that by
  1. Start --> Run
  2. cmd
  3. the command prompt is now running in full screen probably. Get out of it by pressing alt-enter.
  4. Right click the command prompt button on task bar. 
  5. Select defaults (not properties)
  6. Choose window (among window and full screen modes)
  7. If it doesn't work when you restart command prompt, do up to step 4 again.
  8. Then choose properties.
  9. Set to window
  10. Click OK, and select save for future windows with same title.
If you just want a quick escape from full screen, or a quick look into full screen. just press alt-enter

If you liked this post, you may consider following the author of this blog at his original blog Blissful Life (not this one, the original blog) which spreads his views on philosophy, tells about great ways to tweak online experience, simplify life, etc. etc. etc.
Drop me a comment if anything is missing


Don't forget to visit and follow


BLISSFUL LIFE