10033 - Interpreter

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

Moderator: Board moderators

Postby Jan » Fri Oct 14, 2005 11:57 pm

Its tough to generate inputs manually. However, here are some random cases. U can try them.

Input:
Code: Select all
2

299
492
495
399
492
495
399
283
279
689
078
100
000
000
000

456
789
234
453
125
175
183
256
012
100
000


Output:
Code: Select all
16

5


Hope these help.

EDIT : The wrong input set is removed. Sorry for posting it. :oops:
Last edited by Jan on Thu Dec 07, 2006 1:05 pm, edited 1 time in total.
Ami ekhono shopno dekhi...
HomePage
Jan
Guru
 
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh

10033 - input

Postby beloni » Thu Jan 05, 2006 1:58 pm

Anyone can tell me if the following code solve correctly the input of problem 10033???

void CPU::read()
{
int w = 0;
while(1)
{
ram[pc][w] = getchar();
while(ram[pc][w] != '\n')
{
w++;
ram[pc][w] = getchar();
}

if(ram[pc][0] == '\n')
break;
else
{
ram[pc][w] = 0;em string
w = 0;
pc++;
}
}
}
beloni
Learning poster
 
Posts: 66
Joined: Thu Jan 05, 2006 1:41 pm
Location: Pelotas, RS, Brazil

10033 RTE Please help me Jan!!!

Postby beloni » Thu Jan 05, 2006 3:27 pm

I have this sample input posted by JAN:
1

299
492
279
283
078
100
123
345

first code: move register 9 with the value 9
second: mul by two the content of register 9
third: move rigister 7 with the value 9
fourth: move register 8 with value 3

fifth: jump to ram position in register 7 if register 8 is not zero
so... in this case reg 7 contains 9, reg 8 conteisn 3 and reg 9 contains 18.
but the ram position in reg 7 is 000 and we have a infinity loop!!!
beloni
Learning poster
 
Posts: 66
Joined: Thu Jan 05, 2006 1:41 pm
Location: Pelotas, RS, Brazil

a test input

Postby beloni » Thu Jan 05, 2006 3:29 pm

3

299
492
495
399
492
495
399
283
279
689
078
100
000
000
000

456
789
234
453
125
175
183
256
012
100
000

299
492
279
283
078
100
123
345
beloni
Learning poster
 
Posts: 66
Joined: Thu Jan 05, 2006 1:41 pm
Location: Pelotas, RS, Brazil

Postby chunyi81 » Fri Jan 06, 2006 10:26 am

My AC code goes into an infinite loop for this test case as well. I guess you can safely assume the judge contains no such cases.
chunyi81
A great helper
 
Posts: 293
Joined: Sat Jun 21, 2003 4:19 am
Location: Singapore

Postby beloni » Fri Jan 06, 2006 3:33 pm

thanks
so... can you give to me an sample input???
beloni
Learning poster
 
Posts: 66
Joined: Thu Jan 05, 2006 1:41 pm
Location: Pelotas, RS, Brazil

Hmm

Postby tmdrbs6584 » Sun Feb 12, 2006 11:22 am

Why don't you make bigger array size?
User avatar
tmdrbs6584
Learning poster
 
Posts: 98
Joined: Sat Jan 21, 2006 12:45 pm
Location: Busan,Corea(Republic of)

Postby John Herre » Tue Jun 27, 2006 12:32 am

I sent my solution to this problem, and I got ACC, but the last test case makes my program infinite-looping... that's weird... but I have no time to test that manually.

jedihe
John Herre
New poster
 
Posts: 6
Joined: Sat Jun 10, 2006 6:35 pm
Location: Bogota, Colombia

Postby smilitude » Thu Dec 07, 2006 10:28 am

I guess, beloni wanted to say
but the ram position in reg '9' is 000 and we have a infinity loop!!!


he is right with that, anyway.. this input is faulty!
fahim
#include <smile.h>
User avatar
smilitude
Experienced poster
 
Posts: 137
Joined: Fri Jul 01, 2005 12:21 am

Postby Jan » Thu Dec 07, 2006 1:10 pm

Thanks beloni for showing me the error. Those cases were randomly generated, and somehow my old code(which was accepted, too) generated those outputs. But my current code goes into an infinite loop for the case. Sorry for posting such faulty case :oops:.
Ami ekhono shopno dekhi...
HomePage
Jan
Guru
 
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh

10033 is making me crazy!

Postby Bandrosh » Tue Jan 16, 2007 7:03 pm

I have read and re-read this problem so many times that I already know it by heart.

I have searched at the forum and found this sample input and output posted by Jan:

Input:
456
789
234
453
125
175
183
256
012
100
000


Output:
5


Here's the link where I found this input/output:
http://online-judge.uva.es/board/viewto ... ight=10033


What's my problem?
I can't understand how the output can be 5.

First instruction: multiply by 6 the content of register 5
Second: multiply the register 8 content by the content of register 9
Third: set the register 3 the value 4
Fourth: multiply by 3 the content of register 5
Fifth: isn't interpreted
Sixtth: isn't interpreted
Seventh: isn't interpreted
Eighth: set the register 5 the value 6
Nineth: don't go to register 1, beacause the content of register 2 is 0
Tenth: halt interpreter

So we have 6 instructions.
Why is the correct output is 5?
Bandrosh
New poster
 
Posts: 7
Joined: Wed Dec 20, 2006 10:00 pm

Postby tgoulart » Wed Jan 17, 2007 6:10 am

Actually, my program stops when 125 is reached. It is the halt instruction, so the program finishes there, and the subsequent lines should be ignored. This way we have 5 instructions executed, including the 125.
Thiago Sonego Goulart - UFMG/Brazil
tgoulart
New poster
 
Posts: 42
Joined: Sat Oct 21, 2006 8:37 am
Location: Alegrete, Brazil

Postby Bandrosh » Wed Jan 17, 2007 11:46 pm

u have accepted? in ur question?
hehe thnks man, i
Bandrosh
New poster
 
Posts: 7
Joined: Wed Dec 20, 2006 10:00 pm

Postby Bandrosh » Thu Jan 18, 2007 1:01 am

Bandrosh wrote:u have accepted? in ur question?
hehe thnks man, now i have win one Sig Error heheh Ipm staying more crazy
Bandrosh
New poster
 
Posts: 7
Joined: Wed Dec 20, 2006 10:00 pm

Postby tgoulart » Thu Jan 18, 2007 5:09 am

Yes, I got accepted and I hardly doubt that cases like this one would be in the judge's input, unless it's the last case, because of the lines that you have to ignore.

Try to recode your program, you might have done some mistakes, and don't forget that all results are mod 1000!
Thiago Sonego Goulart - UFMG/Brazil
tgoulart
New poster
 
Posts: 42
Joined: Sat Oct 21, 2006 8:37 am
Location: Alegrete, Brazil

PreviousNext

Return to Volume C

Who is online

Users browsing this forum: No registered users and 0 guests