@sharma: dis has been explained to tiwari...ask him...:)
On Fri, Jun 17, 2011 at 3:12 AM, DIPANKAR DUTTA
dutta.dipanka...@gmail.comwrote:
instead of calling swap(ps[0],ps[1]) can u try with swap(ps[0],ps[1]) or
swap(ps[0][0],ps[1][0]) ?
On Fri, Jun 17, 2011 at 5:05 AM, udit sharma
i think u r missing the cases when o is winning and and countx counto then
answer should be no
On Fri, Jun 17, 2011 at 12:19 PM, KK kunalkapadi...@gmail.com wrote:
https://www.spoj.pl/problems/TOE1/
For which test case does this program fail
#includeiostream
#includevector
using
*Friday The 13 Riddle ** **- 17 june *
*
*
*Many people would think Friday the 13th will be an unlucky day. Is it
possible that there is no Friday on 13th through the whole year? How many
Fridays at 13th can we have in a year at most? Can you calculate it out?*
*
* *Update Your Answers at* : Click
@sunny:
This test:
if(! ( (countx == counto + 1) || (countx == counto) ) )
cout no endl;
prints no if countx counto
and this one
if(o x)
cout no endl;
else
cout yes endl;
prints no if both have won or else
no i didn't mean that
in first test u checking if count of X should be either equal of one more
than that of O
and in last u r checking if both are winning or only only one
but what i meant is if O has already won but no of moves of X are greater
than O the answer should be No but your solution
@sunny: why the answer for the case u mentioned is no.. those are
possible set of moves according to me and hence my program outputs
yes
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
To remove all digits left of the rightmost digit one in the binary
representation of some integer what we need to do is this:
ans = no -no
and this is what is exactly asked in this problem of SPOJ:
www.spoj.pl/problems/MZVRK/
#includeiostream
using namespace std;
int main()
{
unsigned long
as you can see in this case no of moves of X are 4 and that of O are 3
as X starts first, after both players has played 3 moves each, O would have
already won the game so next move of X is invalid
i got your solution AC after adding this condition :)
On Fri, Jun 17, 2011 at 2:48 PM, KK
you need to try something better as limits of A and B are very large :)
you can not run a loop from A to B
i have not tried it but the logic is there will be many nos which will give
the same value and we dont need to calculate for them all explicitply :)
On Fri, Jun 17, 2011 at 2:52 PM, KK
how to free memory allocated to an array with new function?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
oops !! :) i'll look into that.. thx
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For
where n is ??
On Fri, Jun 17, 2011 at 3:23 PM, Arpit Sood soodfi...@gmail.com wrote:
i have got AC with O(n)
On Fri, Jun 17, 2011 at 2:59 PM, sunny agrawal sunny816.i...@gmail.comwrote:
you need to try something better as limits of A and B are very large :)
you can not run a loop from A to
lol, i mean in linear time
On Fri, Jun 17, 2011 at 3:27 PM, sunny agrawal sunny816.i...@gmail.comwrote:
where n is ??
On Fri, Jun 17, 2011 at 3:23 PM, Arpit Sood soodfi...@gmail.com wrote:
i have got AC with O(n)
On Fri, Jun 17, 2011 at 2:59 PM, sunny agrawal
but limits of A and B are very large
10^15
how is this possible
am i missing something,
like Max(B-A) = 10^6 or 10^7
On Fri, Jun 17, 2011 at 3:30 PM, Arpit Sood soodfi...@gmail.com wrote:
lol, i mean in linear time
On Fri, Jun 17, 2011 at 3:27 PM, sunny agrawal
Can be done by any standard disk scheduling methods.. i guess
On Tue, Jun 14, 2011 at 2:01 PM, Akshata Sharma
akshatasharm...@gmail.comwrote:
Design an elevator system for a 100 story building. Address all issues,
like number of elevators, speed of each (Not numerically), waiting times
etc.
hmm may be because of [*result will fit into the 64-bit signed integer type
*.]
but i think it can be done optimally
consider if A = 1
B = 7 (taking an easier case)
so for 001,011,101,111 - 1 = 4*1
for 010,110 - 10 = 2*2
for 100 - 100 = 1*4
something like that
so for each A,B we can calculate
if we rotate again prob. of bullet is 1/3.
and if we pull the trigger then prob of bullet will be 1/4.
so its safe to pull the trigger without rotation.
On Wed, Jun 15, 2011 at 1:30 AM, Anika Jain anika.jai...@gmail.com wrote:
henry will give the answer that will favour to save him.. so if
http://www.spoj.pl/problems/MINMOVE/
This code is showing TLE after some 20th test case what else can be
optimized???
try:
import psyco
psyco.full()
except ImportError:
pass
string = input()
minlen = string
length = len(string)
string += string[:]
#print(string)
index = 0
for i in
When a thread locks a mutex only it can unlock it. Does this implies that
even the threads of a single process cannot have access to each others
mutex? I mean, if a thread A of process P has acquired a mutex, then only
thread A can release it or a thread B of same process P can also release it?
Yes, even the threads of a single process cannot have access to each
others mutex.
Mutexes can be applied only to threads in a single process and do not
work between processes as do semaphores.
On Fri, Jun 17, 2011 at 5:40 AM, Akshata Sharma
akshatasharm...@gmail.com wrote:
When a thread
U have got 3 sorted arrays A1 A2 and A3 having m n and p elements
respectively. A gap of 3 arrays is defined to be max distance between
3 nos if they are put on a no line say u pick three 2 12 and 7 then
the gap is 10. Now u have to find an efficient way of chosing 3 nos
from these 3 seperate
merge two and if required third array keeping array tag with the elements
walk over the merged list and see adjacent distance which is minimum with
the condition that the tage of the adjacent elements are different
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
There is very thin line of difference between semaphore and mutex,,
mutex are like binary semaphore ,,but the are concerned about
execution of any piece of code (critical section) ,where as a
semaphore is program construct which can be used to just hold a lock
on a set of resources .
As said by
I think this will work,
have 3 pointers p,q,r pointing last elements of the 3 lists.
compute the difference between each pair.
decrement the index of the list having the min element.
(at each stage, save the current indices and current max distance).
Same logic for the min distance part, just
Given a character array with a set of characters, there might be repetitions
as well, given two characters, you should give the minimum distance between
these two characters in the whole array. O(n) solution is required.
--
Harshal Choudhary,
III Year B.Tech CSE,
NIT Surathkal, Karnataka, India.
Try this:
say i is the index of the first occurrence of the first character
say j is the index of the first occurrence of the second character
say n is length of array
int Min = n+1;
while(i n j n){
int Min = min(Min, abs(i-j))
if(i j){
find next occurrence of first character
}
else{
find
keep 4 pointers
la, lb ra, rb
la = -1; lb=-1; ra=n; rb=n;
l stands for left side, r stands for right side
a is first char b is second char
int minD( char []a, const int n, const char a1, const char b1)
int i=0;
int j=n-1;
int mind=-1;
while (ij)
{
bool chkMin = false;
if (a[i] == a1)
{
issue
axxbabxabaxxb
this solution will not work
rewriting, this should work...
int minD( char []a, const int n, const char a1, const char b1)
int i=0;
int j=n-1;
int mind=-1;
while (ij)
{
bool chkMin = false;
if (a[i] == a1)
{
la=i; chkMin = true;
// if ((la==-1) ||
will this work 4
axxbxba
chars r a,b in this str
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Fri, Jun 17, 2011 at 11:47 PM, sunny agrawal sunny816.i...@gmail.comwrote:
Try this:
say i is the index of the first occurrence of the first
@Ashish: could u plz explain ur algo in detail. walk over the merged
list to get adjacent min distance and different tags this would be of
the order O(m*n) say we merge A1 A2 of size m and n respectively.
Also, now how do u go ahead with the 3rd array? didn't get ur
solution.
Harshal's solution
@Ankit: it seems like mutexes can work between processes. refer to
http://geeksforgeeks.org/?p=9102 m i right?
On Jun 17, 5:56 pm, ankit sambyal ankitsamb...@gmail.com wrote:
Yes, even the threads of a single process cannot have access to each
others mutex.
Mutexes can be applied only to
say the arrays are
a 6,7,9
b 3,4,5
c 1,2,8
the merged array would be
1c
2c
3a
4b
5b
6a
7a
8c
9a
1c,2c cant be compared as they are from same array..next is 3a this implies
3-2 =1 is min distance
P.S: you can merge these in O(m+n+p) [merge from bottom as they are already
sorted]
Best
@Harshal: your terminating condition would be -
lets say we have set the pointers to index 0 of each to get the min
distance.
for index 0 set the min_dist overall to the max distance among the 3
pairs. Now increase the pointer with the minimum value and check the
max distance between pairs. If
@Dumanshu/@Ankit: Of course mutexes can be made to work between processes
(it's an implementation detail). But the *concept* of a mutex is Owner +
(Lock Key) pair. By adding the concept of Owner to a lock, we can ensure
that only the person who locked the lock can open it. This *guarantees*
Hi Rodrigo,
There's a complete field: Data Mining that deals with questions like
these. There are a class of algorithms called recommender algorithms that
analyze past purchase history of a user to make future predictions of items
of interest (similar to the ones implemented on Ebay, Amazon
Optimization options:
1. Don't double the string length. You can use the mod operator (might or
might not be an optimization - profile and see).
2. Work only with indices. There is no need to create a reference to a slice
of the string during each loop pass that checks the if condition. That
What compiler are you using? Version, compile options etc.
--
DK
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/Wf2PvNNjTikJ.
To post to this group, send
using: delete[] arrayPointer;
--
DK
http://twitter.com/divyekapoor
http://www.divye.in
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/1C5XEl8FfiYJ.
To
I am using standard gcc 4.3.2 and the code does not requires any flag to be
required.I also checked the alias if gcc has been aliased to be used with
some option,but that was not the case.My operating system is ubuntu.The
error I get is CONT1D and D1ONE already defined.
I wonder if spoj has a
strangegoogle ask these type of question too.
On Sat, Jun 18, 2011 at 3:07 AM, DK divyekap...@gmail.com wrote:
using: delete[] arrayPointer;
--
DK
http://twitter.com/divyekapoor
http://www.divye.in
--
You received this message because you are subscribed to the Google Groups
Spoj uses -O2 -fomit-frame-pointer when it compiles. Could that be it?
Maybe the %1 and %2 don't work with this option. Just a guess...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
Is it Possible to Sort the stl map on the basis of values though they are
sorted internally on the basis of index ???
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To
42 matches
Mail list logo