101 - The Blocks Problem

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

Moderator: Board moderators

CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Re: Compiler Error? (but works on my machine)

Post by CDiMa »

Minilek wrote:I'm not sure exactly why I'm getting a compiler error. The judge
seems to have a problem with my declaration of command and prep,
but the program compiles and works fine on my computer (I'm
also using gcc). I've also tried submit-o-matic just in case my email
client was adding in extra weird characters, but still a compile error.
Probably your version of gcc is different from the judge's one. Also compilation flags used by the judge may differ from the defaults gcc uses.
Trying to compile with -pedantic may help finding out possible code errors that a standard compile won't show.
Milinek wrote:[c]
/* ... */
main() {
int i,j,k,x,y,z,n;
scanf("%d",&n);
char command[20],prep[20];
[/c]
Try to move all declarations before any line of code...

Ciao!!!

Claudio

Minilek
Learning poster
Posts: 90
Joined: Tue Jul 27, 2004 9:34 am
Location: Cambridge, MA
Contact:

Thanks

Post by Minilek »

Claudio wrote:
Try to move all declarations before any line of code...
Thanks, I did that and now the solution was accepted. Is this very standard? This is the first time I've come across a compiler where you had to make all declarations before any other code.

CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Re: Thanks

Post by CDiMa »

Minilek wrote:Thanks, I did that and now the solution was accepted. Is this very standard? This is the first time I've come across a compiler where you had to make all declarations before any other code.
Well, it's surely an ISO standard:

Code: Select all

$ gcc -pedantic -o minilek minilek.c  
minilek.c: In function `main':
minilek.c:42: warning: ISO C89 forbids mixed declarations and code
minilek.c:52: warning: ISO C89 forbids mixed declarations and code
If you really want to make some declaration local to a piece of code you may wrap it with braces though...
[c]main() {
int i,j,k,x,y,z,n;
scanf("%d",&n);
{
char command[20],prep[20];
for (i=0;i<30;i++) stacks.top = 0;
for (i=0;i<n;i++) push(i,i);
while (1) {
scanf("%s",command);
if (!strcmp(command,"quit")) break;
scanf("%d %s %d",&x,prep,&y);
if (locs[x]==locs[y]) continue;
if (!strcmp(prep,"onto")) while (peek(locs[y])!=y) putback(locs[y]);
if (!strcmp(command,"move")) while (peek(locs[x])!=x) putback(locs[x]);
{
int ind=0,buff[30];
while (peek(locs[x])!=x) buff[ind++] = pop(locs[x]);
buff[ind++] = pop(locs[x]);
for (i=ind-1;i>=0;i--) push(locs[y],buff);
}
}
}
/* ... */[/c]
With this modifications your code should compile fine on the judge.

BTW, it's better if you edit your original code on the board to not show your personal suffix...

Ciao!!!

Claudio

settinghead
New poster
Posts: 2
Joined: Mon Aug 09, 2004 7:08 pm
Location: Singapore
Contact:

help - 101 WA

Post by settinghead »

Here is my code:

//--------------------------------------------------

[cpp]

#include<iostream.h>

const int BOXNUM=200;



struct box
{
struct box *up, *down;
int no;
};

struct command
{
int action; //1:move; 2:pile;
int method; //1:onto; 2:over;
int object1,object2;
bool isquit,invalid;
};

struct box b[BOXNUM];

struct box *findtop(struct box *b) //find the topmost box on the stack
{
struct box *currentbox;
currentbox=b;
while(currentbox->up!=0)
{
currentbox=currentbox->up;
}
return currentbox;
}

bool samestack(struct box *box1, struct box *box2) //judge if the two boxes are in the same stack or are the same
{
struct box *currentbox;
currentbox=box1;
while(currentbox!=0)
{
if(currentbox==box2) return true;
currentbox=currentbox->up;
}
currentbox=box1;
while(currentbox!=0)
{
if(currentbox==box2) return true;
currentbox=currentbox->down;
}
return false;
}

struct command getcommand(int num) //return a command structure defined above
{
char act[5];
int cursor;
struct command cmd;
cin>>act;

cmd.invalid=false;

switch(act[0])
{
case 'm': cmd.action=1; break;
case 'p': cmd.action=2; break;
case 'q': cmd.isquit=true; return(cmd);
}
cin>>cmd.object1;

cin>>act;

switch(act[1])
{
case 'n': cmd.method=1; break;
case 'v': cmd.method=2; break;
}
cin>>cmd.object2;

if (samestack(&(b[cmd.object1]),&(b[cmd.object2])) || cmd.object1>num || cmd.object2>num || cmd.object1<0 || cmd.object2<0) cmd.invalid=true;

return cmd;

}



void initi(int num) //initialization
{
int i;
for(i=0;i<num;i++)
{
b.up=0;
b.down=0;
b.no=i;
}
}



void returnbox(struct box *b) //return the box into its initial position
{
if(b==0) return;
if(b->up!=0) returnbox(b->up);
b->up=0;
b->down->up=0;
b->down=0;
}

void conn(struct box *box1, struct box *box2)
{
if(box1->down!=0) box1->down->up=0;
box1->down=box2;
box2->up=box1;
}

void exec(struct command cmd) //execute the moving process
{
struct box *b1,*b2;
b1=&(b[cmd.object1]);
b2=&(b[cmd.object2]);

//begin analyzing the command from the command structure

switch(cmd.action)
{
case 1: returnbox(b[cmd.object1].up); break; //1: move; 2: pile
}
switch(cmd.method)
{
case 1: returnbox(b[cmd.object2].up); conn(b1, b2); break; //1:onto; 2: over
case 2: b2=findtop(b2); conn(b1,b2); break;
}
}

void displayresult(int num)
{
int i;
struct box *currentbox;
for(i=0;i<num;i++)
{
cout<<i<<":";
if (b.down==0)
{
currentbox=&(b);
while(currentbox!=0)
{
cout<<" "<<(currentbox->no);
currentbox=currentbox->up;
}
}
cout<<endl;
}
}



main()
{
int num;
struct command cmd;
cin>>num;
initi(num);
cmd=getcommand(num);
while(!(cmd.isquit))
{
if(!cmd.invalid) exec(cmd);
cmd=getcommand(num);
}
displayresult(num);
}
[/cpp]

Minilek
Learning poster
Posts: 90
Joined: Tue Jul 27, 2004 9:34 am
Location: Cambridge, MA
Contact:

Post by Minilek »

If you run your code on the example they give you, you'll see that it thinks any command you enter is the quit command.

I changed this piece of your code to make it at least output the right answer on the example.

[cpp]
switch(act[0])
{
case 'm': cmd.action=1; break;
case 'p': cmd.action=2; break;
case 'q': cmd.isquit=true; return(cmd);
}
[/cpp]

is now

[cpp]
switch(act[0])
{
case 'm': cmd.action=1; cmd.isquit=false; break;
case 'p': cmd.action=2; cmd.isquit=false; break;
case 'q': cmd.isquit=true; return(cmd);
}
[/cpp]

settinghead
New poster
Posts: 2
Joined: Mon Aug 09, 2004 7:08 pm
Location: Singapore
Contact:

Post by settinghead »

Yes, you are right. I really appreciate your help. Thanks a lot! :D

Winamp32
New poster
Posts: 1
Joined: Tue Aug 10, 2004 8:27 pm

WA at 101 :/ plz help me

Post by Winamp32 »

[cpp]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct numInf{
int num;
int pos;
numInf * next;//next 1-2-3-4
numInf * previous;//previous 4-3-2-1
numInf * nextS;//next in the Stack
numInf * previousS;//previous in the Stack

}typedef num;


numInf* initArray( int size);
void print(numInf * array);
void moveOver(int a,int b);
void moveOnto(int a,int b);
void pileOver(int a,int b);
void pileOnto(int a,int b);

char input[4][15];
int max;
numInf * numLocation=NULL;





int main(){
int loop=0;
scanf("%d",&max);
numLocation=initArray(max);
while(1){
for(loop=0;loop<4&&strcmp("quit",input[0]);loop++)
scanf("%s",input[loop]);
if(!strcmp("quit",input[0]))
break;
if(atoi(input[1])<=max && atoi(input[3])<=max){
if(!strcmp("move",input[0])){
if(!strcmp("over",input[2]))
moveOver(atoi(input[1]),atoi(input[3]));
else
moveOnto(atoi(input[1]),atoi(input[3]));
}
else
if(!strcmp("over",input[2]))
pileOver(atoi(input[1]),atoi(input[3]));
else
pileOnto(atoi(input[1]),atoi(input[3]));
}
}
print(numLocation);
return 0;
}


numInf * get(int num){
numInf * tmp=numLocation;
while(tmp!=NULL){
if (tmp->num==num)
return tmp;
tmp=tmp->next;
}
return NULL;
}


numInf * getLastInStack(int stackNum){
numInf * tmp=numLocation;
while(tmp!=NULL){
if (tmp->pos==stackNum&&tmp->nextS==NULL)
return tmp;
tmp=tmp->next;
}
return NULL;
}

numInf * getFirstInStack(int stackNum){
numInf * tmp=numLocation;
while(tmp!=NULL){
if (tmp->pos==stackNum&&tmp->previousS==NULL)
return tmp;
tmp=tmp->next;
}
return NULL;
}

int getPosInStack(int num){
int pos=0;
numInf * tmp=get(num);
tmp=tmp->previousS;
while(tmp!=NULL){
pos++;
tmp=tmp->previousS;
}
return pos;
}

void moveOver(int a,int b){
numInf * aa=get(a);
numInf * bb=get(b);
numInf * tmp=NULL;
bb=getLastInStack(bb->pos);
if(aa==bb)
return;
tmp=aa->previousS;
if(tmp!=NULL)
tmp->nextS=aa->nextS;
tmp=aa->nextS;
if(tmp!=NULL)
tmp->previousS=aa->previousS;
aa->nextS=NULL;
aa->previousS=bb;
bb->nextS=aa;
aa->pos=bb->pos;
}

void moveOnto(int a,int b){
numInf * aa=get(a);
numInf * bb=get(b);
numInf * tmp=NULL;
if(aa==bb)
return;
tmp=aa->previousS;
if(tmp!=NULL)
tmp->nextS=aa->nextS;
tmp=aa->nextS;
if(tmp!=NULL)
tmp->previousS=aa->previousS;

aa->nextS=bb->nextS;
tmp=aa->nextS;
if(tmp!=NULL)
tmp->previousS=aa;
aa->previousS=bb;
bb->nextS=aa;
aa->pos=bb->pos;
}

void pileOver(int a,int b){
numInf * aa=get(a);
numInf * bb=get(b);
numInf * tmp=NULL;
if(aa->pos==bb->pos)
return;


tmp=aa->previousS;
if(tmp!=NULL)
tmp->nextS=NULL;

bb=getLastInStack(bb->pos);
aa->previousS=bb;
bb->nextS=aa;
tmp=aa;
while(tmp!=NULL){
tmp->pos=bb->pos;
tmp=tmp->nextS;
}
getLastInStack(bb->pos)->nextS=NULL;
}


void pileOnto(int a,int b){
numInf * aa=get(a);
numInf * bb=get(b);
numInf * tmp=NULL;
if(aa->pos==bb->pos&&getPosInStack(aa->num)<=getPosInStack(bb->num))
return;

tmp=bb->nextS;
if(tmp!=NULL)
tmp->previousS=getLastInStack(aa->pos);/////////mudei isto

getLastInStack(aa->pos)->nextS=bb->nextS;

tmp=aa->previousS;
if(tmp!=NULL)
tmp->nextS=NULL;

aa->previousS=bb;
bb->nextS=aa;
tmp=aa;
while(tmp!=NULL){
tmp->pos=bb->pos;
tmp=tmp->nextS;
}
getLastInStack(bb->pos)->nextS=NULL;
}

numInf* initArray(int size){

int loop;
numInf * previous=NULL, * array=NULL, * first=NULL;
for (loop=0;loop<size;loop++){
array=new numInf;
array->previous=previous;
if(previous!=NULL)
previous->next=array;
else
first=array;
array->pos=loop;
array->num=loop;
previous=array;
array->nextS=NULL;
array->previousS=NULL;
}
array->next=NULL;
return first;
}

void print(numInf * array){
int loop;

numInf * tmp=array;
for(loop=0;loop<max;loop++){
printf("%d:",loop);

while(tmp->previousS!=NULL||tmp->pos!=loop){
tmp=tmp->next;
if(tmp==NULL)
break;
}
if(tmp!=NULL)
while(tmp!=NULL){
printf(" %d",tmp->num);
tmp=tmp->nextS;
}

tmp=array;
if(loop<max-1)
putchar('\n');


}

}

[/cpp]

i've already tried lots of different inputs and i've always got the result I expected but when i submit i receive WA....
plz help me!!
01010111 01101001 01101110 01100001 01101101 01110000 00110011 00110010

Ghust_omega
Experienced poster
Posts: 115
Joined: Tue Apr 06, 2004 7:04 pm
Location: Venezuela

Post by Ghust_omega »

I think that is wrong because dont return some blocks to their initials positions
see
[c]
input :
19
move 1 onto 0
move 0 onto 1
move 0 onto 2
move 2 onto 1
move 4 over 5
move 7 onto 8
move 9 onto 7
move 7 over 9
move 9 over 7
quit

your ouput:

0: 1 2
1:
2: 0
3: 3
4:
5: 5 4
6: 6
7:
8: 8 7 9
9:
10: 10
11: 11
12: 12
13: 13
14: 14
15: 15
16: 16
17: 17
18: 18

my AC codes gives:

0:0
1:1 2
2:
3:3
4:
5:5 4
6:6
7:
8:8 7 9
9:
10:10
11:11
12:12
13:13
14:14
15:15
16:16
17:17
18:18

here are example more short;
input:

4
move 1 onto 0
move 0 onto 1
move 0 onto 2
quit

your ouput:

0: 1
1:
2: 2 0
3: 3


my out:
0:
1:1
2:2 0
3:3

[/c]

Hope it helps :)

clfsoft
New poster
Posts: 1
Joined: Thu Aug 12, 2004 10:14 am

Help 101 TIme Exceed

Post by clfsoft »

It works fine on my machine.
but i got time exceed ,some one help me
thanks in advance.

[c]


#include "stdio.h"
#include "malloc.h"
#include "string.h"
#define ONTO 1
#define OVER 2


typedef struct Node_TAG
{
int value;
int stackNo;
struct Node_TAG* prev;
struct Node_TAG* next;
} Node;

int counts=0;
Node** all=NULL;

void init();
void move(int,int,int);
void pile(int,int,int);
void show();
void printStack(Node *);
void clear(void);


int main()
{
int len=0;
char act[10];
char type[10];
int src,tar;
scanf("%d",&len);
all=(Node**)malloc(sizeof(Node*)*len);
counts=len;
init();
while(1)
{
scanf("%s",act);
if(strcmp("quit",act)==0) break;
if(strcmp("show",act)==0)
{
show();
continue;
}


scanf("%d %s %d",&src,type,&tar);
if(strcmp("move",act)==0)
{
if(strcmp("onto",type)==0)
{
move(src,tar,ONTO);
}else
move(src,tar,OVER);
}
else{
if(strcmp("onto",type)==0)
{
pile(src,tar,ONTO);
}else
pile(src,tar,OVER);
}

}


show();
clear();
return 0;
}
void clear()
{
int i=0;
for(;i<counts;i++)
{
free(all);
}
free(all);

}
void init()
{
int i=0;
for( i=0;i<counts;i++)
{
all=(Node*)malloc(sizeof(Node));
all->stackNo=i;
all->value=i;
all->next=NULL;
all->prev=NULL;
}
}
void resetBehind(Node* src)
{
Node* tmp;
Node* node=src->next;
src->next=NULL;
while(node!=NULL)
{
node->stackNo=node->value;
tmp=node;
node=node->next;
tmp->next=NULL;
tmp->prev=NULL;
}
}

void breakLink(int src)
{
if(all[src]->prev!=NULL)
{
(all[src]->prev)->next=NULL;
all[src]->prev=NULL;
}
}
int isValid(int src,int tar)
{

if(src==tar||all[src]->stackNo==all[tar]->stackNo)
{
return 0;
}
return 1;
}
void updateStackNo(Node *src,int tar)
{
Node* node=src;
while(node!=NULL)
{
node->stackNo=all[tar]->stackNo;
node=node->next;
}
}
void move(int src,int tar,int type)
{
Node *tmp=NULL;
if(!isValid(src,tar))
return;
breakLink(src);

resetBehind(all[src]);

if(type==ONTO){
resetBehind(all[tar]);
all[src]->prev=all[tar];
all[tar]->next=all[src];
}
else
{
tmp=all[tar];
while(tmp->next!=NULL)
{
tmp=tmp->next;
}
tmp->next=all[src];
all[src]->prev=tmp;
updateStackNo(all[src],tar);
}
all[src]->stackNo=all[tar]->stackNo;
}
void pile(int src,int tar,int type)
{
Node *tmp;
if(!isValid(src,tar))
return;

breakLink(src);
if(type==ONTO)
{
resetBehind(all[tar]);
all[tar]->next=all[src];
all[src]->prev=all[tar];
}else
{
tmp=all[tar];
while(tmp->next!=NULL)
{
tmp=tmp->next;
}
tmp->next=all[src];
all[src]->prev=tmp;
}
updateStackNo(all[src],tar);
}
void show()
{
int i=0;
for(;i<counts;i++)
{
printf("%d:",i);
printStack(all);
printf("\n");
}
}
void printStack(Node *node)
{
int stackNo;
if(node->value!=node->stackNo)
return;
stackNo=node->stackNo;
while(node!=NULL)
{
printf("%d ",node->value);
node=node->next;
}
}
[/c]

okris
New poster
Posts: 2
Joined: Wed Aug 25, 2004 2:07 am
Location: Mexico

Please help me!! problem 101

Post by okris »

please, help me!!!
I send this code to online-judge and tell me:
compile error

here
C++

Minilek
Learning poster
Posts: 90
Joined: Tue Jul 27, 2004 9:34 am
Location: Cambridge, MA
Contact:

Post by Minilek »

i get a compiler error too (use -ansi so you can see them). usually to be safe i compile with -ansi -Wall -pedantic

Code: Select all

C:\acmuva>gpp -ansi test.cpp
gpp -ansi test.cpp
In file included from c:/djgpp/lang/cxx/3.34/bits/locale_facets.tcc:41,
                 from c:/djgpp/lang/cxx/3.34/locale:47,
                 from c:/djgpp/lang/cxx/3.34/bits/ostream.tcc:37,
                 from c:/djgpp/lang/cxx/3.34/ostream:535,
                 from c:/djgpp/lang/cxx/3.34/iostream:45,
                 from test.cpp:1:
c:/djgpp/lang/cxx/3.34/cmath:107: error: `acosf' not declared
c:/djgpp/lang/cxx/3.34/cmath:110: error: `asinf' not declared
c:/djgpp/lang/cxx/3.34/cmath:113: error: `atanf' not declared
c:/djgpp/lang/cxx/3.34/cmath:116: error: `atan2f' not declared
c:/djgpp/lang/cxx/3.34/cmath:119: error: `ceilf' not declared
c:/djgpp/lang/cxx/3.34/cmath:122: error: `coshf' not declared
c:/djgpp/lang/cxx/3.34/cmath:125: error: `expf' not declared
c:/djgpp/lang/cxx/3.34/cmath:128: error: `floorf' not declared
c:/djgpp/lang/cxx/3.34/cmath:131: error: `fmodf' not declared
c:/djgpp/lang/cxx/3.34/cmath:134: error: `frexpf' not declared
c:/djgpp/lang/cxx/3.34/cmath:137: error: `ldexpf' not declared
c:/djgpp/lang/cxx/3.34/cmath:140: error: `logf' not declared
c:/djgpp/lang/cxx/3.34/cmath:143: error: `log10f' not declared
c:/djgpp/lang/cxx/3.34/cmath:146: error: `modff' not declared
c:/djgpp/lang/cxx/3.34/cmath:149: error: `powf' not declared
c:/djgpp/lang/cxx/3.34/cmath:152: error: `sinhf' not declared
c:/djgpp/lang/cxx/3.34/cmath:155: error: `tanf' not declared
c:/djgpp/lang/cxx/3.34/cmath:158: error: `tanhf' not declared
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::acos(float)':
c:/djgpp/lang/cxx/3.34/cmath:184: error: `acosf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::asin(float)':
c:/djgpp/lang/cxx/3.34/cmath:204: error: `asinf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::atan(float)':
c:/djgpp/lang/cxx/3.34/cmath:222: error: `atanf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::atan2(float, float)':
c:/djgpp/lang/cxx/3.34/cmath:240: error: `atan2f' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::ceil(float)':
c:/djgpp/lang/cxx/3.34/cmath:260: error: `ceilf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::cosh(float)':
c:/djgpp/lang/cxx/3.34/cmath:288: error: `coshf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::exp(float)':
c:/djgpp/lang/cxx/3.34/cmath:306: error: `expf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::floor(float)':
c:/djgpp/lang/cxx/3.34/cmath:334: error: `floorf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::fmod(float, float)':
c:/djgpp/lang/cxx/3.34/cmath:352: error: `fmodf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::frexp(float, int*)':
c:/djgpp/lang/cxx/3.34/cmath:372: error: `frexpf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::ldexp(float, int)':
c:/djgpp/lang/cxx/3.34/cmath:391: error: `ldexpf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::log(float)':
c:/djgpp/lang/cxx/3.34/cmath:411: error: `logf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::log10(float)':
c:/djgpp/lang/cxx/3.34/cmath:429: error: `log10f' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::modf(float, float*)':
c:/djgpp/lang/cxx/3.34/cmath:447: error: `modff' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `long double std::modf(long double, 
   long double*)':
c:/djgpp/lang/cxx/3.34/cmath:461: error: `::modfl' undeclared (first use here)
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::pow(float, float)':
c:/djgpp/lang/cxx/3.34/cmath:486: error: `powf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::sinh(float)':
c:/djgpp/lang/cxx/3.34/cmath:528: error: `sinhf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::tan(float)':
c:/djgpp/lang/cxx/3.34/cmath:556: error: `tanf' undeclared in namespace `
   __gnu_cxx::__c99_binding'
c:/djgpp/lang/cxx/3.34/cmath: In function `float std::tanh(float)':
c:/djgpp/lang/cxx/3.34/cmath:574: error: `tanhf' undeclared in namespace `
   __gnu_cxx::__c99_binding'

wolf
New poster
Posts: 34
Joined: Sun Aug 22, 2004 4:20 am
Location: Poland

Post by wolf »

Hi !
I'm not sure, but maybe online-judge don't knows what is it <fstream>. :-?

Stas
New poster
Posts: 5
Joined: Sat Jul 03, 2004 5:15 pm
Location: Kyrgyzstan
Contact:

Post by Stas »

Check your mailbox :) there are a lot of "comile error" replays from judge!

Eduard
Experienced poster
Posts: 183
Joined: Fri Sep 26, 2003 2:54 pm
Location: Armenia,Yerevan

101WA

Post by Eduard »

I have some questions about this ptoblem.
1.Is there only one input(or I must read while not eof)
2.Can ther be such input.

3
move 0 onto 1
move 0 onto 2
move1 0 onto 2 <------Can be such line
do 1 onto 1 <------Can be such line
quite

Please give some tests.I can't find my mistake.
Thanks.
someone who like to solve informatic problems.
http://acm.uva.es/cgi-bin/OnlineJudge?AuthorInfo:29650

Ghust_omega
Experienced poster
Posts: 115
Joined: Tue Apr 06, 2004 7:04 pm
Location: Venezuela

Post by Ghust_omega »

Hi Eduard that comands are wrong and i dont belive that can be I/O like you said before, if help, I read the input like this,this is from my AC code:

Code: Select all

scanf("%s",in);
		if( (strcmp(in,"quit") == 0 ) )
			break;
		scanf("%d %s %d",&a,in2,&b);
                .........see the move or pile any..........

				
and I read untill i get the "quit"
this is some I/O maybe you can test
Input:

Code: Select all

19
move 1 onto 0
move 0 onto 1
move 0 onto 2
move 2 onto 1
move 4 over 5
move 7 onto 8
move 9 onto 7
move 7 over 9
move 9 over 7
move 11 over 10
move 12 over 10
move 13 over 10
move 14 over 10
move 16 over 15
move 17 over 15
move 18 over 15
move 16 onto 14
pile 17 onto 12
move 15 over 10
pile 17 onto 14
pile 15 over 7
pile 6 over 5
pile 3 onto 9
quit
Ouput:

Code: Select all

0:0
1:1 2
2:
3:
4:
5:5 4 6
6:
7:
8:8 7 9 3
9:
10:10 11 12
11:
12:
13:13
14:14 17
15:15
16:16
17:
18:18

this format of ouput gives P.E. because i cut and paste but is ok
Hope its helps
Keep posting :wink:

Post Reply

Return to “Volume 1 (100-199)”