706 - LCD Display

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

Moderator: Board moderators

Mushfiqur Rahman
Learning poster
Posts: 56
Joined: Tue Jun 13, 2006 5:18 pm
Location: (CSE, SUST) Sylhet, Bangladesh
Contact:

Sorry for that.

Post by Mushfiqur Rahman »

I found my bug and got AC just after sending the previous post.
Thanks to Debashis. I would be happy if u didn't the 'pondity'.

4l1
New poster
Posts: 2
Joined: Tue Mar 13, 2007 6:19 pm

Post by 4l1 »

Program specification says n is between 0 and 99,999,999. Handling your input should not be necessary.

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

Post by Q.Qnick »

how about me
i get a Presentation Error !!
i don't know how to solve that kind error

here is my code:

#include<stdio.h>
#include<string.h>

int i,j,k;
int s,cnt,c=0;
char a[1000000];

main(){
while(scanf("%d %s",&s,&a)==2){
if(c!=0){
printf("\n");
}
c++;
cnt=strlen(a);

for(i=0;i<cnt;i++){
for(j=0;j<s+2;j++){
if( j>0 && j<s+1 && (a=='0' || a=='2' || a=='3' || a=='5' || a=='6' || a=='7' || a=='8' || a=='9') ){
printf("-");
}
else{
printf(" ");
}
}
if(i!=cnt-1)
printf(" ");
}
printf("\n");
for(j=0;j<s;j++){
for(i=0;i<cnt;i++){
for(k=0;k<s+2;k++){
if( k==0 && ( a=='0' ||a=='4' || a[i]=='5' || a[i]=='6' || a[i]=='8' || a[i]=='9') ){
printf("|");
}
else if(k==s+1 && (a[i]=='1' || a[i]=='2' || a[i]=='3' || a[i]=='4' || a[i]=='7' || a[i]=='8' || a[i]=='9' || a[i]=='0')){
printf("|");
}
else{
printf(" ");
}
}
if(i!=cnt-1)
printf(" ");
}
printf("\n");
}
for(i=0;i<cnt;i++){
for(j=0;j<s+2;j++){
if( ( a[i]=='2' || a[i]=='3' || a[i]=='4' || a[i]=='5' || a[i]=='6' || a[i]=='8' || a[i]=='9') && j>0 && j<s+1){
printf("-");
}
else{
printf(" ");
}
}
if(i!=cnt-1)
printf(" ");
}
printf("\n");
for(j=0;j<s;j++){
for(i=0;i<cnt;i++){
for(k=0;k<s+2;k++){
if( k==0 && ( a[i]=='2' || a[i]=='6' || a[i]=='8' || a[i]=='0') ){
printf("|");
}
else if(k==s+1 && (a[i]=='1' || a[i]=='3' || a[i]=='4' || a[i]=='5' || a[i]=='6' || a[i]=='7' || a[i]=='8' || a[i]=='9' || a[i]=='0')){
printf("|");
}
else{
printf(" ");
}
}
if(i!=cnt-1)
printf(" ");
}
printf("\n");
}
for(i=0;i<cnt;i++){
for(j=0;j<s+2;j++){
if( ( a[i]=='2' || a[i]=='3' || a[i]=='5' || a[i]=='6' || a[i]=='8' || a[i]=='9' || a[i]=='0') && j>0 && j<s+1){
printf("-");
}
else{
printf(" ");
}
}
if(i!=cnt-1)
printf(" ");
}
printf("\n");
}


}

gfz87
New poster
Posts: 4
Joined: Sun Apr 22, 2007 1:12 am

Post by gfz87 »

I try a lot of test cases, and my program seems to run ok and it gives a correct output, but judge still gives me a WA. Here is my C++ code:

Code: Select all

#include <iostream>

using namespace std;

struct par
{
	int s;
	char *n;
};

char **getnro(int s, char *n)
{
	int i, j, k, l;
	char **nro;
	nro = new char*[2*s+4];
	for (i = 0; i < 2*s+3; i++)
	{
		nro[i] = new char[(s+3) * strlen(n) + 1];
		for (j = 0; j < (s + 3) * strlen(n) - 1; j++)
			nro[i][j] = ' ';
		nro[i][j] = 0;
	}

	for (k = 0; k < strlen(n); k++)
	{
		if (n[k] >= 0x30 && n[k] <= 0x39)
		{
			l = n[k] - 0x30;
			switch(l)
			{
			case 0:
				for (i = 0; i < s; i++)
				{
					nro[0][1+i+(k*(s+3))] = '-';
					nro[2*s+2][1+i+(k*(s+3))] = '-';
				}
				for (i = 1; i < s + 1; i++)
				{
					nro[i][(k*(s+3))] = '|';
					nro[i][s+1+(k*(s+3))] = '|';
					nro[i+s+1][(k*(s+3))] = '|';
					nro[i+s+1][s+1+(k*(s+3))] = '|';
				}
				break;
			case 1:
				for (i = 1; i < s + 1; i++)
				{
					nro[i][s+1+(k*(s+3))] = '|';
					nro[i+s+1][s+1+(k*(s+3))] = '|';
				}
				break;
			case 2:
				for (i = 0; i < s; i++)
				{
					nro[0][1+i+(k*(s+3))] = '-';
					nro[s+1][1+i+(k*(s+3))] = '-';
					nro[2*s+2][1+i+(k*(s+3))] = '-';
				}
				for (i = 1; i < s + 1; i++)
				{
					nro[i][s+1+(k*(s+3))] = '|';
					nro[i+s+1][k*(s+3)] = '|';
				}
				break;
			case 3:
				for (i = 0; i < s; i++)
				{
					nro[0][1+i+(k*(s+3))] = '-';
					nro[s+1][1+i+(k*(s+3))] = '-';
					nro[2*s+2][1+i+(k*(s+3))] = '-';
				}
				for (i = 1; i < s + 1; i++)
				{
					nro[i][s+1+(k*(s+3))] = '|';
					nro[i+s+1][s+1+(k*(s+3))] = '|';
				}
				break;
			case 4:
				for (i = 0; i < s; i++)
				{
					nro[s+1][1+i+(k*(s+3))] = '-';
				}
				for (i = 1; i < s + 1; i++)
				{
					nro[i][k*(s+3)] = '|';
					nro[i][s+1+(k*(s+3))] = '|';
					nro[i+s+1][s+1+(k*(s+3))] = '|';
				}
				break;
			case 5:
				for (i = 0; i < s; i++)
				{
					nro[0][1+i+(k*(s+3))] = '-';
					nro[s+1][1+i+(k*(s+3))] = '-';
					nro[2*s+2][1+i+(k*(s+3))] = '-';
				}
				for (i = 1; i < s + 1; i++)
				{
					nro[i][k*(s+3)] = '|';
					nro[i+s+1][s+1+(k*(s+3))] = '|';
				}
				break;
			case 6:
				for (i = 0; i < s; i++)
				{
					nro[0][1+i+(k*(s+3))] = '-';
					nro[s+1][1+i+(k*(s+3))] = '-';
					nro[2*s+2][1+i+(k*(s+3))] = '-';
				}
				for (i = 1; i < s + 1; i++)
				{
					nro[i][0+(k*(s+3))] = '|';
					nro[i+s+1][k*(s+3)] = '|';
					nro[i+s+1][s+1+(k*(s+3))] = '|';
				}
				break;
			case 7:
				for (i = 0; i < s; i++)
				{
					nro[0][1+i+(k*(s+3))] = '-';
				}
				for (i = 1; i < s + 1; i++)
				{
					nro[i][s+1+(k*(s+3))] = '|';
					nro[i+s+1][s+1+(k*(s+3))] = '|';
				}
				break;
			case 8:
				for (i = 0; i < s; i++)
				{
					nro[0][1+i+(k*(s+3))] = '-';
					nro[s+1][1+i+(k*(s+3))] = '-';
					nro[2*s+2][1+i+(k*(s+3))] = '-';
				}
				for (i = 1; i < s + 1; i++)
				{
					nro[i][k*(s+3)] = '|';
					nro[i][s+1+(k*(s+3))] = '|';
					nro[i+s+1][k*(s+3)] = '|';
					nro[i+s+1][s+1+(k*(s+3))] = '|';
				}
				break;
			case 9:
				for (i = 0; i < s; i++)
				{
					nro[0][1+i+(k*(s+3))] = '-';
					nro[s+1][1+i+(k*(s+3))] = '-';
					nro[2*s+2][1+i+(k*(s+3))] = '-';
				}
				for (i = 1; i < s + 1; i++)
				{
					nro[i][k*(s+3)] = '|';
					nro[i][s+1+(k*(s+3))] = '|';
					nro[i+s+1][s+1+(k*(s+3))] = '|';
				}
				break;
			}
		}
	}
	return nro;
}

void main()
{
	int s, i, j;
	unsigned long c=0;
	par **nro;
	char **salida, *n;

	n = new char[9];
	cin >> s >> n;
	while (n[0] == '0' && strlen(n) > 1)
	{
		for (i = 0; i < 8; i++)
			n[i] = n[i+1];
		n[i]=0;
	}
	nro = new par*[4*1000];

	while (s > 0 || n[0] != '0')
	{
		if (!(strlen(n) == 1 && n[0] == '0') && s > 0)
		{
			nro[c] = new par;
			nro[c]->s = s;
			nro[c++]->n = n;
			n = new char[9];
		}
		cin >> s >> n;
		while (n[0] == '0' && strlen(n) > 1)
		{
			for (i = 0; i < 8; i++)
				n[i] = n[i+1];
			n[i]=0;
		}
	}

	for (i = 0; i < c; i++)
	{	
		salida = getnro(nro[i]->s, nro[i]->n);
		for (j = 0; j < nro[i]->s * 2 + 3; j++)
			cout << salida[j] << endl;
		if (i < c - 1)
			cout << endl;
	}
}
I hope someone can help me out. Greetings

Neli
New poster
Posts: 7
Joined: Thu May 03, 2007 8:35 am
Location: Sylhet
Contact:

WA in706

Post by Neli »

I checked out all possible condition.But got Wrong answer.
Anyone there help me?

gfz87
New poster
Posts: 4
Joined: Sun Apr 22, 2007 1:12 am

Post by gfz87 »

Ok, my program just got accepted, I didn't initiate the variable where it stores all the votes

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

Good for you. Could you please remove your code now?

sfelixjr
New poster
Posts: 9
Joined: Wed Apr 25, 2007 3:29 pm
Location: Brazil
Contact:

my code got wa

Post by sfelixjr »

could you help me?
my code is doing all that u've said,
it is right, but i got WA, here is:

Code: Select all

import java.io.IOException;

class Main {
	static String ReadLn(int maxLg) // utility function to read from stdin
	{
		byte lin[] = new byte[maxLg];
		int lg = 0, car = -1;
		try {
			while (lg < maxLg) {
				car = System.in.read();
				if ((car < 0) || (car == ' ') || (car == '\n'))
					break;
				lin[lg++] += car;
			}
		} catch (IOException e) {
			return (null);
		}

		if ((car < 0) && (lg == 0))
			return (null); // eof
		return (new String(lin, 0, lg));
	}

	public static void main(String[] args) {
		Main d = new Main();
		d.begin();

	}

	void begin() {
		String input = "";
		int tamanho = 0;
		input = Main.ReadLn(255);
		boolean imp = false;
		while (!input.equals("0")) {
			if (imp) {
				System.out.println();
			}
			imp = true;
			tamanho = Integer.parseInt(input);
			int cont = 0;
			int[] valo = new int[255];
			while ((input = ReadLn(1)) != null) {
				if (!input.equals("")) {
					valo[cont] = Integer.parseInt(input);
					cont++;
				} else
					break;
			}
			int[] valor = new int[cont];
			for (int i = 0; i < valor.length; i++) {
				valor[i] = valo[i];
			}
			etapa1(valor, tamanho);

			input = Main.ReadLn(255);

		}
	}

	void etapa1(int[] vetor, int tamanho) {
		System.out.print(" ");
		for (int o = 0; o < vetor.length; o++) {
			if (vetor[o] == 1 || vetor[o] == 4) {
				for (int i = 0; i < tamanho; i++)
					System.out.print(" ");
				System.out.print(" ");
			} else {
				for (int i = 0; i < tamanho; i++)
					System.out.print("-");
				System.out.print(" ");
			}
			if (o != vetor.length - 1)
				System.out.print("  ");
		}
		System.out.println();
		etapa2(vetor, tamanho);

	}

	void etapa2(int[] vetor, int tamanho) {

		for (int k = 0; k < tamanho; k++) {
			for (int o = 0; o < vetor.length; o++) {

				if (vetor[o] == 1 || vetor[o] == 2 || vetor[o] == 3
						|| vetor[o] == 7) {
					System.out.print(" ");
					for (int i = 0; i < tamanho; i++)
						System.out.print(" ");
					System.out.print("|");
					if (o != vetor.length - 1)
						System.out.print(" ");

				} else if (vetor[o] == 5 || vetor[o] == 6) {
					System.out.print("|");
					for (int i = 0; i < tamanho; i++)
						System.out.print(" ");
					System.out.print(" ");
					if (o != vetor.length - 1)
						System.out.print(" ");

				} else {

					System.out.print("|");
					for (int i = 0; i < tamanho; i++)
						System.out.print(" ");
					System.out.print("|");
					if (o != vetor.length - 1)
						System.out.print(" ");

				}

			}
			System.out.println();
		}
		etapa3(vetor, tamanho);
	}

	void etapa3(int[] vetor, int tamanho) {
		System.out.print(" ");
		for (int o = 0; o < vetor.length; o++) {
			if (vetor[o] == 1 || vetor[o] == 7 || vetor[o] == 0) {
				for (int i = 0; i < tamanho; i++)
					System.out.print(" ");
				if (o != vetor.length - 1)
					System.out.print("  ");
			} else {
				for (int i = 0; i < tamanho; i++)
					System.out.print("-");
				if (o != vetor.length - 1)
					System.out.print("  ");
			}
			System.out.print(" ");
		}
		System.out.println();
		etapa4(vetor, tamanho);

	}

	void etapa4(int[] vetor, int tamanho) {

		for (int k = 0; k < tamanho; k++) {
			for (int o = 0; o < vetor.length; o++) {

				if (vetor[o] == 1 || vetor[o] == 3 || vetor[o] == 4
						|| vetor[o] == 5 || vetor[o] == 7 || vetor[o] == 9) {
					System.out.print(" ");
					for (int i = 0; i < tamanho; i++)
						System.out.print(" ");
					System.out.print("|");
					if (o != vetor.length - 1)
						System.out.print(" ");

				} else if (vetor[o] == 2) {
					System.out.print("|");
					for (int i = 0; i < tamanho; i++)
						System.out.print(" ");
					System.out.print(" ");
					if (o != vetor.length - 1)
						System.out.print(" ");

				} else {

					System.out.print("|");
					for (int i = 0; i < tamanho; i++)
						System.out.print(" ");
					System.out.print("|");
					if (o != vetor.length - 1)
						System.out.print(" ");

				}

			}
			System.out.println();
		}
		etapa5(vetor, tamanho);
	}

	void etapa5(int[] vetor, int tamanho) {
		System.out.print(" ");
		for (int o = 0; o < vetor.length; o++) {
			if (vetor[o] == 1 || vetor[o] == 4 || vetor[o] == 7) {
				for (int i = 0; i < tamanho; i++)
					System.out.print(" ");
				if (o != vetor.length - 1)
					System.out.print("  ");
			} else {
				for (int i = 0; i < tamanho; i++)
					System.out.print("-");
				if (o != vetor.length - 1)
					System.out.print("  ");
			}
			System.out.print(" ");
		}
		System.out.println();
	}
}
please, thanks

pillo
New poster
Posts: 4
Joined: Sun Sep 16, 2007 9:14 pm
Location: Mx - UVAQ

706

Post by pillo »

I dont know what is the problem, I am doing everything rigth... pls someone help me :(

Code: Select all

import java.io.*;
import java.util.*;

class Main
{
    static String ReadLn (int maxLg)  // utility function to read from stdin
    {
        byte lin[] = new byte [maxLg];
        int lg = 0, car = -1;
        String line = "";

        try
        {
            while (lg < maxLg)
            {
                car = System.in.read();
                if ((car < 0) || (car == '\n')) break;
                lin [lg++] += car;
            }
        }
        catch (IOException e)
        {
            return (null);
        }

        if ((car < 0) && (lg == 0)) return (null);  // eof
        return (new String (lin, 0, lg));
    }

    public static void main (String args[])  // entry point from OS
    {
        Main myWork = new Main();  // create a dinamic instance
        myWork.Begin();            // the true entry point
    }

    void Begin()
    {

        String cade[]=new String[100];
        String cero[]=new String[100];
        String uno[]=new String[100];
        String dos[]=new String[100];
        String tres[]=new String[100];
        String cuatro[]=new String[100];
        String cinco[]=new String[100];
        String seis[]=new String[100];
        String siete[]=new String[100];
        String ocho[]=new String[100];
        String nueve[]=new String[100];
        String recive[]=new String[3];
        int ww=0;
        int contador=0;
        boolean bo=false;
        while(!bo){
        recive=Main.ReadLn(2555).split(" ");
        int s=Integer.parseInt(recive[0]);
        String var="".valueOf(Long.parseLong(recive[1]));
        long numero=Long.parseLong(var);
        if(s>0 && s<=10 && numero >=0 && numero <=99999999 ){
        int x=0;
        contador=0;
        cad(cade,100);
        for(int i=0;i<var.length();i++){
            if(var.charAt(i)=='0')cero=inc(s,0);
            else if(var.charAt(i)=='1')uno=inc(s,1);
            else if(var.charAt(i)=='2')dos=inc(s,2);
            else if(var.charAt(i)=='3')tres=inc(s,3);
            else if(var.charAt(i)=='4')cuatro=inc(s,4);
            else if(var.charAt(i)=='5')cinco=inc(s,5);
            else if(var.charAt(i)=='6')seis=inc(s,6);
            else if(var.charAt(i)=='7')siete=inc(s,7);
            else if(var.charAt(i)=='8')ocho=inc(s,8);
            else if(var.charAt(i)=='9')nueve=inc(s,9);          
        }
            
            
        for(int y=0;y<((s*2)+3);y++){
            x=0;
               for(int w=0;w<var.length();w++){             //3er for
                   if(var.charAt(w)=='0'){
                       cade[y]+=cero[y];
                   }
                   else if(var.charAt(w)=='1'){
                       cade[y]+=uno[y];
                   }
                    else if(var.charAt(w)=='2'){
                       cade[y]+=dos[y];
                   }
                    else if(var.charAt(w)=='3'){
                       cade[y]+=tres[y];
                   }
                   else if(var.charAt(w)=='4'){
                       cade[y]+=cuatro[y];
                   }
                    else if(var.charAt(w)=='5'){
                       cade[y]+=cinco[y];
                   }
                    else if(var.charAt(w)=='6'){
                       cade[y]+=seis[y];
                   }
                   else if(var.charAt(w)=='7'){
                       cade[y]+=siete[y];
                   }
                    else if(var.charAt(w)=='8'){
                       cade[y]+=ocho[y];
                   }
                    else if(var.charAt(w)=='9'){
                       cade[y]+=nueve[y];
                   }
                   if(x+1<var.length()){
                        cade[y]+=" ";
                         x++; 
                   }
               }
            
        }
        for(int f=0;f<((s*2)+3);f++){
          System.out.println(cade[f]);
        } System.out.println();
            
        
         }else if(s==0 && numero==0)
              bo=true;
        }
       
         
           
    }
    public static String[] inc(int s, int num){
        String esp=" ";
        String gui="-";
        String cadena[]=new String[100];
        cad(cadena,100);
        
        int cont=0, y=0;
        for(int con=1;con<s;con++){
            esp+=" ";
            gui+="-";
        }
            if(num==0){
                cont=0;y=0;
                cadena[y++]=" "+gui+" ";
                while(cont!=s){
                    cadena[y++]="|"+esp+"|";
                    cont++;
                }cont=0;
                    cadena[y++]="  "+esp;
                while(cont!=s){
                    cadena[y++]="|"+esp+"|";
                    cont++;
                }cont=0;
                    cadena[y++]=" "+gui+" ";
            
            }
        
        else if(num==1){
                cont=0;y=0;
                    cadena[y++]="  "+esp;
                while(cont!=s){
                    cadena[y++]=esp+" |";
                    cont++;
                }cont=0;
                    cadena[y++]="  "+esp;
                while(cont!=s){
                    cadena[y++]=esp+" |";
                    cont++;
                }cont=0;
                    cadena[y++]="  "+esp;
                             
            }
        else if(num==2){
                cont=0;y=0;
                cadena[y++]=" "+gui+" ";
                while(cont!=s){
                    cadena[y++]=esp+" |";
                    cont++;
                }cont=0;
                cadena[y++]=" "+gui+" ";
                while(cont!=s){
                    cadena[y++]="| "+esp;
                    cont++;
                }cont=0;
                cadena[y++]=" "+gui+" ";
           }
        else if(num==3){
            cont=0;y=0;
            cadena[y++]=" "+gui+" ";
            while(cont!=s){
            cadena[y++]=esp+" |";
            cont++;
            }cont=0;
            cadena[y++]=" "+gui+" ";
            while(cont!=s){
            cadena[y++]=esp+" |";
            cont++;
            }cont=0;
            cadena[y++]=" "+gui+" ";
            
        }
        else if(num==4){
                cont=0;y=0;
                    cadena[y++]="  "+esp;
                while(cont!=s){
                    cadena[y++]="|"+esp+"|";
                    cont++;
                }cont=0;
                    cadena[y++]=" "+gui+" ";
                while(cont!=s){
                    cadena[y++]=esp+" |";
                    cont++;
                }cont=0;
                    cadena[y++]="  "+esp;
                             
            }
        else if(num==5){
                cont=0;y=0;
                cadena[y++]=" "+gui+" ";
                while(cont!=s){
                    cadena[y++]="|"+esp+" ";
                    cont++;
                }cont=0;
                cadena[y++]=" "+gui+" ";
                while(cont!=s){
                    cadena[y++]=" "+esp+"|";
                    cont++;
                }cont=0;
                cadena[y++]=" "+gui+" ";
           }
        else if(num==6){
            cont=0;y=0;
            cadena[y++]=" "+gui+" ";
            while(cont!=s){
            cadena[y++]="|"+esp+" ";
            cont++;
            }cont=0;
            cadena[y++]=" "+gui+" ";
            while(cont!=s){
            cadena[y++]="|"+esp+"|";
            cont++;
            }cont=0;
            cadena[y++]=" "+gui+" ";
            
        }
        else if(num==7){
                cont=0;y=0;
                    cadena[y++]=" "+gui+" ";
                while(cont!=s){
                    cadena[y++]=" "+esp+"|";
                    cont++;
                }cont=0;
                    cadena[y++]=" "+esp+" ";
                while(cont!=s){
                    cadena[y++]=esp+" |";
                    cont++;
                }cont=0;
                    cadena[y++]="  "+esp;
                             
            }
        else if(num==8){
                cont=0;y=0;
                cadena[y++]=" "+gui+" ";
                while(cont!=s){
                    cadena[y++]="|"+esp+"|";
                    cont++;
                }cont=0;
                cadena[y++]=" "+gui+" ";
                while(cont!=s){
                    cadena[y++]="|"+esp+"|";
                    cont++;
                }cont=0;
                cadena[y++]=" "+gui+" ";
           }
        else if(num==9){
            cont=0;y=0;
            cadena[y++]=" "+gui+" ";
            while(cont!=s){
            cadena[y++]="|"+esp+"|";
            cont++;
            }cont=0;
            cadena[y++]=" "+gui+" ";
            while(cont!=s){
            cadena[y++]=" "+esp+"|";
            cont++;
            }cont=0;
            cadena[y++]=" "+gui+" ";
        }
        return cadena;
    }
    public static String[] cad(String[] cadena,int x){
        for(int y=0;y<x;y++)
            cadena[y]="";
        return cadena;
    }
 
    
}
[/quote]

pillo
New poster
Posts: 4
Joined: Sun Sep 16, 2007 9:14 pm
Location: Mx - UVAQ

I still getting W.A

Post by pillo »

can u tell me ur considerations for this problem?
GL & Hf =)
-:[ Pi* ]:-

pillo
New poster
Posts: 4
Joined: Sun Sep 16, 2007 9:14 pm
Location: Mx - UVAQ

W.A

Post by pillo »

idk what its happening with the mine... someone can tell me a cases?
GL & Hf =)
-:[ Pi* ]:-

pillo
New poster
Posts: 4
Joined: Sun Sep 16, 2007 9:14 pm
Location: Mx - UVAQ

still W.A....

Post by pillo »

plz someone help me!! t.t
GL & Hf =)
-:[ Pi* ]:-

fabiofabris
New poster
Posts: 3
Joined: Fri Oct 12, 2007 4:33 pm

WA also...

Post by fabiofabris »

Please Help!

I'm getting a WA also...
My program seens alright... Did a lot of testing and couldn't find any error;

- I'm considering leading zeros (printing them)
- I'm printing the blank columns between digits
- I'm also printing new lines after the numbers
- I've read in a topic that printing two new lines in the last output could solve the problem... No luck...

Test Input:
3 8391
2 933
5 00094
2 0
4 1234567890
0 0

Code: Select all

Output:
 ---   ---   ---       
|   |     | |   |     |
|   |     | |   |     |
|   |     | |   |     |
 ---   ---   ---       
|   |     |     |     |
|   |     |     |     |
|   |     |     |     |
 ---   ---   ---       

 --   --   -- 
|  |    |    |
|  |    |    |
 --   --   -- 
   |    |    |
   |    |    |
 --   --   -- 

 -----   -----   -----   -----         
|     | |     | |     | |     | |     |
|     | |     | |     | |     | |     |
|     | |     | |     | |     | |     |
|     | |     | |     | |     | |     |
|     | |     | |     | |     | |     |
                         -----   ----- 
|     | |     | |     |       |       |
|     | |     | |     |       |       |
|     | |     | |     |       |       |
|     | |     | |     |       |       |
|     | |     | |     |       |       |
 -----   -----   -----   -----         

 -- 
|  |
|  |
    
|  |
|  |
 -- 

        ----   ----          ----   ----   ----   ----   ----   ---- 
     |      |      | |    | |      |           | |    | |    | |    |
     |      |      | |    | |      |           | |    | |    | |    |
     |      |      | |    | |      |           | |    | |    | |    |
     |      |      | |    | |      |           | |    | |    | |    |
        ----   ----   ----   ----   ----          ----   ----        
     | |           |      |      | |    |      | |    |      | |    |
     | |           |      |      | |    |      | |    |      | |    |
     | |           |      |      | |    |      | |    |      | |    |
     | |           |      |      | |    |      | |    |      | |    |
        ----   ----          ----   ----          ----   ----   ---- 



Output (with point instead of spaces):
.---...---...---.......
|...|.....|.|...|.....|
|...|.....|.|...|.....|
|...|.....|.|...|.....|
.---...---...---.......
|...|.....|.....|.....|
|...|.....|.....|.....|
|...|.....|.....|.....|
.---...---...---.......

.--...--...--.
|..|....|....|
|..|....|....|
.--...--...--.
...|....|....|
...|....|....|
.--...--...--.

.-----...-----...-----...-----.........
|.....|.|.....|.|.....|.|.....|.|.....|
|.....|.|.....|.|.....|.|.....|.|.....|
|.....|.|.....|.|.....|.|.....|.|.....|
|.....|.|.....|.|.....|.|.....|.|.....|
|.....|.|.....|.|.....|.|.....|.|.....|
.........................-----...-----.
|.....|.|.....|.|.....|.......|.......|
|.....|.|.....|.|.....|.......|.......|
|.....|.|.....|.|.....|.......|.......|
|.....|.|.....|.|.....|.......|.......|
|.....|.|.....|.|.....|.......|.......|
.-----...-----...-----...-----.........

.--.
|..|
|..|
....
|..|
|..|
.--.

........----...----..........----...----...----...----...----...----.
.....|......|......|.|....|.|......|...........|.|....|.|....|.|....|
.....|......|......|.|....|.|......|...........|.|....|.|....|.|....|
.....|......|......|.|....|.|......|...........|.|....|.|....|.|....|
.....|......|......|.|....|.|......|...........|.|....|.|....|.|....|
........----...----...----...----...----..........----...----........
.....|.|...........|......|......|.|....|......|.|....|......|.|....|
.....|.|...........|......|......|.|....|......|.|....|......|.|....|
.....|.|...........|......|......|.|....|......|.|....|......|.|....|
.....|.|...........|......|......|.|....|......|.|....|......|.|....|
........----...----..........----...----..........----...----...----.


it is kindda ugly coz this font is not monospace...

I just can't understand what is wrong... Plz someone show me how stupid I am.

Code: Select all

#include <stdio.h>
#include <stdlib.h>

char n[1000];
int size;

void printLevel(int level,int dig){
	int i,j,k;
	if(level==0){
		for(i=0;i<dig;i++){
			if((n[i]==1)||(n[i]==4)){
				for(j=0;j<(size+2);j++)printf(" ");
				if(i!=dig-1)printf(" ");
			}else{
				printf(" ");
				for(j=1;j<(size+1);j++)printf("-");				
				printf(" ");
				if(i!=dig-1)printf(" ");
			}
		}
	puts("");
	}else if(level==1){
		for(k=0;k<size;k++){
			for(i=0;i<dig;i++){
				if((n[i]==5)||(n[i]==6)){
					printf("|");
					for(j=0;j<(size+1);j++)printf(" ");
					if(i!=dig-1)printf(" ");
				}else if((n[i]==1)||(n[i]==2)||(n[i]==3)||(n[i]==7)){
					for(j=0;j<(size+1);j++)printf(" ");
					printf("|");
					if(i!=dig-1)printf(" ");
				}else{
					printf("|");
					for(j=0;j<size;j++)printf(" ");
					printf("|");
					if(i!=dig-1)printf(" ");
				}
			}
			puts("");
		}		
	}else if(level==2){
		for(i=0;i<dig;i++){
			if((n[i]==1)||(n[i]==7)||(n[i]==0)){
				for(j=0;j<(size+2);j++)printf(" ");
				if(i!=dig-1)printf(" ");
			}else{
				printf(" ");
				for(j=1;j<(size+1);j++)printf("-");				
				printf(" ");
				if(i!=dig-1)printf(" ");
			}
		}
	puts("");
	}else if (level==3){
		for(k=0;k<size;k++){
			for(i=0;i<dig;i++){
				if((n[i]==2)){
					printf("|");
					for(j=0;j<(size+1);j++)printf(" ");
					if(i!=dig-1)printf(" ");
				}else if((n[i]==1)||(n[i]==3)||(n[i]==3)||(n[i]==4)||(n[i]==5)||(n[i]==7)||(n[i]==9)){
					for(j=0;j<(size+1);j++)printf(" ");
					printf("|");
					if(i!=dig-1)printf(" ");
				}else{
					printf("|");
					for(j=0;j<size;j++)printf(" ");
					printf("|");
					if(i!=dig-1)printf(" ");
				}
			}
			puts("");
		}	
	}else{
		for(i=0;i<dig;i++){
			if((n[i]==1)||(n[i]==4)||(n[i]==7)){
				for(j=0;j<(size+2);j++)printf(" ");
				if(i!=dig-1)printf(" ");
			}else{
				printf(" ");
				for(j=1;j<(size+1);j++)printf("-");				
				printf(" ");
				if(i!=dig-1)printf(" ");
			}
		}
	puts("");
	}
}


int main(){
	int dig,i;
	char tmp;
	while(1){
		scanf("%d",&size);
		if(!size)break;
		dig=0;
		scanf("%c",&tmp);
		while(1){
			scanf("%c",&tmp);
			if(tmp=='\n')break;
			if(tmp=='0'&&dig==0)continue;
			n[dig++]=tmp-'0';
		}
		for(i=0;i<5;i++){
			printLevel(i,dig);
		}	
		puts("");
	}
	puts("");
	return 0;
}

fabiofabris
New poster
Posts: 3
Joined: Fri Oct 12, 2007 4:33 pm

Solved!

Post by fabiofabris »

I finally made it!!!

Some considerations about this problem:
- X 0001 should print 1
- X 0000 should print 0
- 0 N should finish execution only if N is 0 (important)
- Probably there are white spaces between numbers and/or before the new line in the input;
- Make sure that you are printing a blank column BETWEEN digits.

I think this input is kinnda trick...

Saswat2603
New poster
Posts: 15
Joined: Tue Feb 12, 2008 10:42 am
Location: Bhubaneswar, Orissa, India

Re: my AC code that doesn't consider the above points

Post by Saswat2603 »

Hi fabiofabris !!

I think you are mistaken :oops: in the first three points :

- X 0001 should print 1
- X 0000 should print 0
- 0 N should finish execution only if N is 0 (important)


My AC code does NOT fulfill any of these 3 criteria BUT it's AC :lol: !!!

If, you want my AC code, contact me @--> saswat.sourav@gmail.com

Post Reply

Return to “Volume 7 (700-799)”