Page 9 of 12

Posted: Tue Oct 03, 2006 7:14 am
by newton
i changed the size of the array but still got runtime error.
what is my fault? may u check it again plz.

Posted: Thu Oct 05, 2006 4:31 am
by daveon
Change

Code: Select all

char str1[1000001];
int    str2[1000001];
to

Code: Select all

char str1[1000001];
char str2[1000001];
and make these global variables.

Then change

Code: Select all

while(gets(str1)!=NULL) 
To

Code: Select all

while(scanf("%s",str1)==1)
Which is now a little more robust. And also, add #include <string.h>.

Posted: Thu Oct 05, 2006 8:46 am
by newton
dear davion

i have done all the changes u told but ACM (stupid) Compiler gave me WA. i am really in a great trouble with the chilly problem. May u help again.







advanced thanx.

Posted: Thu Oct 05, 2006 5:38 pm
by Vexorian
your alg has a little flaw, try this: (char would overflow)

Code: Select all

0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1
500 501
The correct answer for that input is Yes.

Posted: Sat Oct 07, 2006 6:58 am
by newton
deleted

Posted: Sat Oct 07, 2006 6:05 pm
by Vexorian
Maybe your compiler does not have an 8 bits size char, or maybe it is another compiler related issue.

I compiled your program with gcc (which is the compiler the online judge uses) and it failed with that input

Posted: Mon Mar 12, 2007 12:45 pm
by newton
why dont you give me simple I/O which can help me to seek out my problem. please check my code. find if there any locical error.
my Turbo c++ compiler is so poor to find critical error.




Code: Select all

               please help or i will die






newton................................ simply the best

Posted: Mon Mar 12, 2007 12:59 pm
by newton
please help me!

goto the link please
http://online-judge.uva.es/board/viewto ... 9623#59623

Posted: Mon Mar 12, 2007 4:03 pm
by rio
Bug here.

Code: Select all

 printf("Case: %d\n",++Case); 
And I think the str2 should be int.
----
calm down.

Posted: Thu Mar 15, 2007 10:23 am
by newton
devion and rio,

your comments are contradictory to each other!
what should i do
should str2 be in char or int type?
plz clarify me.
i am in great trouble.

Posted: Tue May 01, 2007 7:41 am
by legnaleurc
I have found why I got TLE.

Code: Select all

........blahblahblah
	while(!cin.eof())
	{
		getline(cin, line);
	........................blahblahblah
Because the last char. of input file could be space, it won't get EOF
This cause limitless loop

Use while(getline(cin, line)) instead of while(!cin.eof()) and I got Accepted.

tle...............help plzzzzzzzzz

Posted: Sat Jun 09, 2007 3:23 pm
by SARKAR
for god"s sake can anyone tell y the hell i am getting out of time.......

plzzzzzzzzz help

Code: Select all

#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
int count=0;
string s;
while(cin>>s)
{
if(s[0]=='\n')
return 0;
if(s[0]==' ')
return 0;
count++;
printf("Case %i:\n",count);
int a,b,c;
cin>>a;
for(int i=1;i<=a;++i)
{
cin>>b>>c;
if(b>c)
{
char temp=s[b];
b=c;
c=temp;
}
char a1=s[b];
while(b<=c)
{
if(a1!=s[b])
{
cout<<"No\n";
b=-101;
break;
}
++b;
}
if(b!=-101)
cout<<"Yes\n";
}
}	
}



[/b]

Posted: Sat Jun 09, 2007 5:46 pm
by Jan
Your algorithm is not ok for this problem. For each query you dont have to run any loop. Just initially check the whole pattern and use some technique. Then you can solve each query in just O(1).

Hope it helps.

wa now

Posted: Sat Jun 09, 2007 7:06 pm
by SARKAR
yes i totally underestimated this problrm.now this time i am sure my algo is right(hope so)


plzzzzzzzz jan telll me y i m getting WA...........

which cases i am missing...................

Code: Select all

/*code removed*/
[/code]

Posted: Sun Jun 10, 2007 11:37 am
by Jan
I think your code is correct as well as your algorithm. So, try submitting it again. And don't forget to remove your code.