10033 - Interpreter

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

Moderator: Board moderators

tgoulart
New poster
Posts: 42
Joined: Sat Oct 21, 2006 8:37 am
Location: Alegrete, Brazil

Post by 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

Bandrosh
New poster
Posts: 7
Joined: Wed Dec 20, 2006 10:00 pm

Post by 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

Post by 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

tgoulart
New poster
Posts: 42
Joined: Sat Oct 21, 2006 8:37 am
Location: Alegrete, Brazil

Post by 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

Bandrosh
New poster
Posts: 7
Joined: Wed Dec 20, 2006 10:00 pm

Post by Bandrosh » Thu Jan 18, 2007 11:48 pm

pois

tgoulart
New poster
Posts: 42
Joined: Sat Oct 21, 2006 8:37 am
Location: Alegrete, Brazil

Post by tgoulart » Sat Jan 20, 2007 3:46 pm

I hardly doubt that cases like this one would be in the judge's input
Sorry, I didn't noticed that I store all the data before calculating, so It's not true...
Thiago Sonego Goulart - UFMG/Brazil

Q.Qnick
New poster
Posts: 5
Joined: Tue Mar 13, 2007 12:58 pm

10033

Post by Q.Qnick » Tue Mar 20, 2007 3:23 pm

here is my code
how can i solve the problem of time limit

#include<stdio.h>

int s,i,j;
int RAM[20][3],REG[10],ans;
char save[6];
main(){
scanf("%d\n",&s);
j=0;
for(i=0;i<s;i++){
j=0;
while(gets(save)){
if(!save[0])break;
if(save[0]=='0'&& save[1]=='0' &&save[2]=='0')
break;
RAM[j][0]=save[0]-'0';
RAM[j][1]=save[1]-'0';
RAM[j][2]=save[2]-'0';
j++;

}
for(;j<20;j++){
RAM[j][0]=0;
RAM[j][1]=0;
RAM[j][2]=0;
}
for(ans=0,j=0;;){
if(RAM[j][0]==1)
{
ans++;
break;
}
else if(RAM[j][0]==2)
{
REG[ RAM[j][1] ] = RAM[j][2];
}
else if(RAM[j][0]==3)
{
REG[ RAM[j][1] ] += RAM[j][2];
REG[ RAM[j][1] ]%=1000;
}
else if(RAM[j][0]==4)
{
REG[ RAM[j][1] ] *= RAM[j][2];
REG[ RAM[j][1] ]%=1000;
}
else if(RAM[j][0]==5)
{
REG[ RAM[j][1] ] = REG[ RAM[j][2] ];
}
else if(RAM[0]==6)
{
REG[ RAM[j][1] ] += REG[ RAM[j][2] ];
REG[ RAM[j][1] ]%=1000;
}
else if(RAM[j][0]==7)
{
REG[ RAM[j][1] ] *= REG[ RAM[j][2] ];
REG[ RAM[j][1] ]%=1000;
}
else if(RAM[j][0]==8)
{
REG[ RAM[j][1] ] = RAM[j][ REG[ RAM[j][2] ] ];
}
else if(RAM[j][0]==9)
{
RAM[j][ REG[ RAM[j][2] ] ] = REG[ RAM[j][1] ];
}
else if(RAM[j][0]==0 && REG[ RAM[j][2] ]!=0)
{
j = REG[ RAM[j][1] ];
}
ans++;
j++;
}
printf("%d\n",ans);
if(i!=s-1){
printf("\n");
}
}
}

Q.Qnick
New poster
Posts: 5
Joined: Tue Mar 13, 2007 12:58 pm

Post by Q.Qnick » Tue Mar 20, 2007 4:35 pm

some body help me T.T

Q.Qnick
New poster
Posts: 5
Joined: Tue Mar 13, 2007 12:58 pm

Post by Q.Qnick » Wed Mar 21, 2007 2:42 pm

i do some change , but it isn't work .
can some one let me know where is the plb.
thx a lot .



#include<stdio.h>

int s,i,j,k;
int RAM[1000][3],REG[10]={0},ans;
char save[6];
main(int argc,char *argv[]){
/*FILE *fp;
fp=fopen(argv[1],"r");*/
fscanf(stdin,"%d\n",&s);
/*printf("%d\n",s);*/
j=0;
for(i=0;i<s;i++){
j=0;
while(fgets(save,6,stdin)!=NULL){
if(save[0]=='\n')
{
break;
}
else
{
RAM[j][0]=save[0]-'0';
RAM[j][1]=save[1]-'0';
RAM[j][2]=save[2]-'0';
j++;
}
}
for(k=j;k<1000;k++){
RAM[k][0]=0;
RAM[k][1]=0;
RAM[k][2]=0;
}
/*for(k=0;k<j;k++){
printf("%d %d %d %d\n",i,RAM[k][0],RAM[k][1],RAM[k][2]);
}
printf("\n==\n");*/

for(k=0;k<10;k++){
REG[k]=0;
}

ans=0;
for(j=0;;){
if(RAM[j][0]==1)
{
ans++;
break;
}
else if(RAM[j][0]==2)
{
REG[ RAM[j][1] ] = RAM[j][2];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==3)
{
REG[ RAM[j][1] ] += RAM[j][2];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==4)
{
REG[ RAM[j][1] ] *= RAM[j][2];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==5)
{
REG[ RAM[j][1] ] = REG[ RAM[j][2] ];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==6)
{
REG[ RAM[j][1] ] += REG[ RAM[j][2] ];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==7)
{
REG[ RAM[j][1] ] *= REG[ RAM[j][2] ];
REG[ RAM[j][1] ]%=1000;
j++;
}
else if(RAM[j][0]==8)
{
REG[ RAM[j][1] ] = RAM[j][ REG[ RAM[j][2] ] ];
j++;
}
else if(RAM[j][0]==9)
{
RAM[j][ REG[ RAM[j][2] ] ] = REG[ RAM[j][1] ];
j++;
}
else if(RAM[j][0]==0)
{
if(REG[ RAM[j][2] ]!=0)
{
j = REG[ RAM[j][1] ];
}
else
{
j++;
}
}
if(j==1000){
j=0;
}
ans++;
}
printf("%d\n",ans);
if(i!=s-1){
printf("\n");
}
}
}


pbfox
New poster
Posts: 2
Joined: Wed Mar 21, 2007 3:50 am

Help me! Input code?

Post by pbfox » Wed Mar 21, 2007 4:03 pm

Help me! Input Code?

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

pbfox
New poster
Posts: 2
Joined: Wed Mar 21, 2007 3:50 am

Re: 10033 - Interpreter - I need a multi-testcase input

Post by pbfox » Wed Mar 21, 2007 4:14 pm

:cry: my code is wrong, but anyway...
help me,please!

Bandrosh
New poster
Posts: 7
Joined: Wed Dec 20, 2006 10:00 pm

Post by Bandrosh » Wed May 09, 2007 7:02 pm

sim gourlat to precisando de ajuda, agora q terminou o semestre v

hardcode
New poster
Posts: 4
Joined: Thu Jul 05, 2007 2:58 am

Post by hardcode » Thu Jul 05, 2007 3:00 am

tgoulart wrote: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.
Why does your program stop when 125 is reached tgoulart? Isn't 100 mean to be the halt instruction? I'm confused. Thanks for your time!

tgoulart
New poster
Posts: 42
Joined: Sat Oct 21, 2006 8:37 am
Location: Alegrete, Brazil

Post by tgoulart » Thu Jul 05, 2007 4:28 am

hardcode wrote:
tgoulart wrote: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.
Why does your program stop when 125 is reached tgoulart? Isn't 100 mean to be the halt instruction? I'm confused. Thanks for your time!
My program stops because I verify the instruction by the first digit, and 1 is the halt operation. But if you take a look at the table, you will see that 125 isn't a valid instruction.
Thiago Sonego Goulart - UFMG/Brazil

Post Reply

Return to “Volume 100 (10000-10099)”