41 / 46
Mar 2012

Please edit the very first post of this forum then. I wrote a Haskell program which received TLE. I am convinced I wrote the equivalent program in C which was accepted.

-ljr

Right, thanks for the suggestion.

A primality test such as Miller-Rabin (or Solovay-Strassen, or Fermat, or AKS, or whatever) is the wrong approach for this problem. You want a variation of the Sieve of Eratosthenes. Search the forum for suggestions, some of the posts practically spell out the answer.

The sieve is nice and fast in a... was going to say non-FP but I haven't tested them all so I'll say not-Haskell. If you look at my previous posts I pointed out that I built a source file that hard-coded all primes needed to cover the problem space. It still hit TLE. That's SoE with all the legwork pre-calculated so I'll admit the solution needed is beyond me.

Now I don't really care. I tried SoE. I tried Miller-Rabin. I tried pre-calc and all hit TLE. I won't argue that the problem isn't with me because obviously other folks have used haskell and are well below the limit. My original post was following up on the first post in this thread. I had an algorithm which hit TLE in a functional language. Same alg in C was accepted. I posted. Got told, 'What I really meant is "just make your program faster"'.

Nice system. Not useful as a learning tool for trying a new language. My bad.

-ljr

Well, not all the SPOJ problems are fit for all purposes. At least you can't say we didn't warn you wink (at the bottom of the problem text).

4 months later

Would it be possible to run the problems for let's say double time, and then indicate the time with the TLE if available? Then it would give some indication whether one is near or not.

1 month later

CANDY 1 can't be done in Guile afaik. Just ran 2 bogus scripts with dummy output, and the best result I got was 0.99 sec out of the 1s limit on reading the input.

2 years later

having TLE using F# but solved these problems using C++ (C#):

(1) Problem http://www.spoj.pl/problems/LEXISORT/1
Statistic for F#: http://www.spoj.pl/ranks/LEXISORT/lang=FS (0)
my code: http://www.spoj.pl/files/src/4509752/

(2) Problem http://www.spoj.pl/problems/INTEST/
Statistic for F#: http://www.spoj.pl/ranks/INTEST/lang=FS (0)
my code: http://www.spoj.pl/files/src/4509704/

(3) Problem http://www.spoj.pl/problems/TSORT/
Statistic for F#: http://www.spoj.pl/ranks/TSORT/lang=FS (0)
my code: http://www.spoj.pl/files/src/4509667/ (O(n) algo - TLE)

why not to do for example such a think for F# ad other slow langs:
if functional_language then TLE = TLE * 2 (or mult by 3)

its really very sad not to have an opportunity to solve problems using your fav language.

You're stepping on shaky ground here I guess. Haskell and Ocaml have a bunch of solutions for mentioned problems.
So not "functional languages", but just F# mono.
Also zero solutions may not really mean something - F# was added not so long time ago.

2 months later
3 months later
5 months later

Co tu jest nie tak?

#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
int main(int argc, char *argv[])
{
	double t,a,b,c,k,n,p=0,h=0,s=0, z=0;
	cin>>t;
	cout<<endl;
	while(t--)
	{
		cin>>n;
		cout<<" ";
		cin>>k;
		cout<<endl;
		while(n--)
		{
		cin>>a;
		cout<<" ";
		cin>>b;
		cout<<" ";
		cin>>c;
		cout<<endl;
		p=(a+b+c)/2;
		h=sqrt(p*(p-a)*(p-b)*(p-c));
		s+=h;
		p=0;
		h=0;
	    }
	  if(a<b+c && b<c+a && c<a+b)
		{  
s/=10000;	
    
z=(s*k)*1000;	    
	    cout <<endl<<  round( z ) << endl;
			}
     	else
     	cout<<"0"<<endl;
		z=0;
		s=0;
		cout<<endl;
}
	system("pause");
	return 0;
}

Widze tu dodatkowe spacje i endl'y, które powodują, raczej na pewno, WA.

Jak masz wczytane 3 liczby np. "1 2 3", to po wczytaniu kazdej nie musisz dawać spacji...
wystarczy:

cin>>a>>b>>c;
//lub
cin>>a;
cin>>b;
cin>>c;
// lub scanfem

i tutaj:

cout <<endl<<  round( z ) << endl;

ten pierwszy endl też jest chyba zbędny

Witam, generalnie kod mam podobny do kolegi wyżej ale bez wszystkich spacji i endli. Wyniki dla przykładu ze spoja mam dobre, a biorąc pod uwagę małą liczbę rozwiązań jest tu jakiś haczyk/kruczek. Oto mójkod
[bbone=text,641]AC[/bbone]
Podpowie ktoś co mogę zrobić?
@edit
Dziękuję smile Przeszło.

2 months later

Nie mam pojęcia co jest źle. Może mi ktoś podsunąć pomysł na poprawkę?

AC
1 year later

Hej!
Program zwraca dobre wyniki dla przykładowych danych ze SPOJ'a, ale np. dla testu kokoska zwraca 119... Nie wiem, w czym tkwi błąd. Czy moglibyście mi pomóc? wink

Niezawodna pomoc użytkowników forum! :D
3 years later

I have this issue with my python submission for LAZYPROG. Iam using the best approach, its c ++ version is working. python version is getting tle.
pls check the code

1 year later
7 months later
2 years later

I am not sure why all other platforms work very well with jvm (java, kotlin), python while only spoj cannot?
Is there something wrong with spoj’s infrastructure in general?

Why not just giving a big enough memory and timeout in general to all solutions and if the solution is slow, just tell the users smt like “90% of submissions using your language are faster than your solution”.