10324 - Zeros and Ones

All about problems in Volume 103. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

User avatar
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton » Tue Oct 03, 2006 7:14 am

i changed the size of the array but still got runtime error.
what is my fault? may u check it again plz.

daveon
Experienced poster
Posts: 229
Joined: Tue Aug 31, 2004 2:41 am
Location: TORONTO, CANADA

Post by daveon » Thu Oct 05, 2006 4:31 am

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>.

User avatar
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton » Thu Oct 05, 2006 8:46 am

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.

Vexorian
Learning poster
Posts: 100
Joined: Sat Aug 26, 2006 5:50 am

Post by Vexorian » Thu Oct 05, 2006 5:38 pm

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.

User avatar
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton » Sat Oct 07, 2006 6:58 am

deleted
Last edited by newton on Sat Jul 14, 2007 1:15 pm, edited 1 time in total.

Vexorian
Learning poster
Posts: 100
Joined: Sat Aug 26, 2006 5:50 am

Post by Vexorian » Sat Oct 07, 2006 6:05 pm

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

User avatar
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton » Mon Mar 12, 2007 12:45 pm

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

User avatar
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton » Mon Mar 12, 2007 12:59 pm

please help me!

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

User avatar
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio » Mon Mar 12, 2007 4:03 pm

Bug here.

Code: Select all

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

User avatar
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton » Thu Mar 15, 2007 10:23 am

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.

legnaleurc
New poster
Posts: 4
Joined: Mon Apr 23, 2007 6:05 am

Post by legnaleurc » Tue May 01, 2007 7:41 am

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.

SARKAR
New poster
Posts: 21
Joined: Tue May 22, 2007 4:18 pm

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

Post by SARKAR » Sat Jun 09, 2007 3:23 pm

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]

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Sat Jun 09, 2007 5:46 pm

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.
Ami ekhono shopno dekhi...
HomePage

SARKAR
New poster
Posts: 21
Joined: Tue May 22, 2007 4:18 pm

wa now

Post by SARKAR » Sat Jun 09, 2007 7:06 pm

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]
Last edited by SARKAR on Sun Jun 10, 2007 12:45 pm, edited 1 time in total.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Sun Jun 10, 2007 11:37 am

I think your code is correct as well as your algorithm. So, try submitting it again. And don't forget to remove your code.
Ami ekhono shopno dekhi...
HomePage

Post Reply

Return to “Volume 103 (10300-10399)”