#include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,n) for (int i=0; i=0; i--) #define pb push_back #define fi first #define se second typedef long long ll; typedef pair PII; char buf[1000]; char tmp[1000]; char tmp2[1000]; #define MAX 1010 int action[MAX]; int value[MAX]; int status[MAX]; #define OK 0 #define NO_ACC 1 #define INSF 2 #define SAME 3 #define INTER 4 #define EXIST 5 #define WITHDRAW 1 #define CREATE 2 #define DEPOSIT 3 #define TRANSFER 4 void fail(){ fseek(stdin,2,SEEK_SET); } int solveScenario(){ int cnt=-1; while(true){ fgets(buf,1000,stdin); if (buf[0]=='e') break; if (buf[0]=='g') return 0; int a,b; cnt++; if (buf[0]=='w') { sscanf(buf,"%s %d.%d: %s",tmp,&a,&b,tmp2); action[cnt]=WITHDRAW; value[cnt]=100*a+b; if (tmp2[0]=='n') status[cnt]=NO_ACC; if (tmp2[0]=='o') status[cnt]=OK; if (tmp2[0]=='i') status[cnt]=INSF; continue; } if (buf[0]=='c') { sscanf(buf, "%s %s",tmp,tmp2); action[cnt]=CREATE; if (tmp2[0]=='o') status[cnt]=OK; if (tmp2[0]=='a') status[cnt]=EXIST; continue; } if (buf[0]=='d') { sscanf(buf,"%s %d.%d: %s",tmp,&a,&b,tmp2); action[cnt]=DEPOSIT; value[cnt]=100*a+b; if (tmp2[0]=='n') status[cnt]=NO_ACC; if (tmp2[0]=='o') status[cnt]=OK; continue; } if (buf[0]=='t') { //printf("parising '%s' \n",buf); sscanf(buf,"%s %d.%d: %s",tmp,&a,&b,tmp2); // printf("%d %d %s\n\n",a,b,tmp2); action[cnt]=TRANSFER; value[cnt]=100*a+b; if (tmp2[0]=='n') status[cnt]=NO_ACC; if (tmp2[0]=='i') status[cnt]=INSF; if (tmp2[0]=='s') status[cnt]=SAME; if (tmp2[0]=='o') status[cnt]=OK; if (tmp2[0]=='i') status[cnt]=INTER; } } fgets(buf,10,stdin); printf("100\n"); printf("0001/0 0.00\n"); printf("0099/1 10000.00\n"); int ucty[5000]; FOR(q,5000) ucty[q]=0; for (int q=2; q<99; q++) { printf("%04d/0 10000.00\n",q); ucty[q]=1000000; } int uctov=500; cnt++; FOR(q,cnt) { if (action[q]==CREATE) { if (status[q]==EXISTS) printf("create 0001/0\n"); else printf("create %04d/0",uctov++); } if (action[q]==DEPOSIT) { if (status[q]==NO_ACC) printf("deposit 0000/0\n"); else { printf("deposit 0002/0\n"); ucty[2]+=value[q]; } } if (action[q]==WITHDRAW){ if (status[q]==NO_ACC) printf("withdraw 0000/0\n"); else if (status[q]==INSF) printf("withdraw 0000/1\n"); else if (status[q]==OK) { int qq=99; for (int w=99; w>1; w--) if (ucty[w]>value[q]) {q=w; break; } if (ucty[qq]value[q]) { printf("transfer 0099/1 0002/0\n"); ucty[99]-=value[q]; ucty[2]+=value[q]; } else { for (int q=98; q>1; q--) if (ucty[q]>value){ printf("transfer %04d 0099/1\n",q); ucty[q]-=value[q]; ucty[99]+=value[q]; break; } } } } } printf("end\n\n"); return 1; } int main(){ while (solveScenario()); printf("0\n"); }