Sunday, July 9, 2017
MICEMAZE SPOJ Solution C++ (Dijkstra's Algorithm)
Algorithm:
1. Reverse edges.
2. Select E as source and run Dijkstra's Algorithm.
1. Reverse edges.
2. Select E as source and run Dijkstra's Algorithm.
Saturday, July 8, 2017
BUSYMAN SPOJ Greedy C
Algorithm:
1. Sort on end times.
2. Iterate over sorted list
2.1 If the current activity overlaps, skip it
2.2 If it doesn't increase count of answer. Set new time to end time of this activity.
Code:
1. Sort on end times.
2. Iterate over sorted list
2.1 If the current activity overlaps, skip it
2.2 If it doesn't increase count of answer. Set new time to end time of this activity.
Code:
Friday, July 7, 2017
SPOJ/DQUERY solution Sort+Segment Tree (C)
https://apps.topcoder.com/forums/?module=Thread&threadID=627423
Solution:
Solution:
Tuesday, January 24, 2017
Friday, January 20, 2017
Minimal Perl code to generate 32 characters alphanumeric random string.
This code generates a random 32 characters string.
Output (6 runs):
NUPtwWIRTDOTmoBZ2xgDtceHjvjUloAi
7rKd8024tNZdgCUJJjlrQlBqKh53lpUV
dSPKG8uODbriqmbtEFDvrypbrx22BhuO
A5ozpCeKTCY322otKSlhiAcOV4E8LwZS
DTKcTiUJ7xGFO3kR6Tmh29J5rT88jBoJ
y7Q7VeCY7q83P7c2D2JK9C8svy59efXw
use v5.22; print join '', map {state $c = ['a'..'z', 'A'..'Z', '0'..'9']; $$c[rand @$c]} 0..31;
Output (6 runs):
NUPtwWIRTDOTmoBZ2xgDtceHjvjUloAi
7rKd8024tNZdgCUJJjlrQlBqKh53lpUV
dSPKG8uODbriqmbtEFDvrypbrx22BhuO
A5ozpCeKTCY322otKSlhiAcOV4E8LwZS
DTKcTiUJ7xGFO3kR6Tmh29J5rT88jBoJ
y7Q7VeCY7q83P7c2D2JK9C8svy59efXw
Tuesday, January 3, 2017
Printing column data one by one - awk
Suppose you have a file like this:
You need to get this output:
, you can use this awk code:
You need to get this output:
, you can use this awk code:
Subscribe to:
Posts (Atom)