1. 

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 457 Linear Cellular Automata
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=94&problem=398&mosmsg=Submission+received+with+ID+7888155
*
* @author Barny Porcio
* @version 1.0, 04/10/2010
*
* Method : -
* Status : Accepted
* Runtime: 0.576
*/

import java.util.Scanner;


public class LinearCellularAutomata457 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
boolean flag = false;
for (int i = sc.nextInt(); i>0 ; --i ){
if (flag)
System.out.println();
else
flag = true;
int[] DNA = new int[10];
for (int o = 0; o < DNA.length; ++o){
DNA[o] = sc.nextInt();
}
int[] dishesold = new int[42];
dishesold[20] = 1;
int[] dishesnew = new int[42];
for(int u = 0 ;u < 50; ++u){
for (int hh = 1; hh<dishesold.length-1;++hh){
switch (dishesold[hh]) {
case 0:
System.out.print(' ');
break;
case 1:
System.out.print('.');
break;
case 2:
System.out.print('x');
break;
case 3:
System.out.print('W');
break;
default:
break;
}
dishesnew[hh] = DNA[(dishesold[hh-1]+dishesold[hh]+ dishesold[hh+1])];
}
System.out.println();
int[] temp = dishesold;
dishesold = dishesnew;
dishesnew = temp;
}

}
}
}

2.

/**
* FWP: Ausgewaehlte Probleme aus dem ACM (SS10)
*
* Method: ad hoc
* Problem: 457 - Linear Cellular Automata
* Accepted: 0.184
* @author Evgeni Pavlidis
*
*/

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

class Main {

public static void main(String...args)
{
Scanner scanner = new Scanner(System.in);
StringBuffer output = new StringBuffer();
int testCases = scanner.nextInt();
int[] dna = new int[10];
int[] dish;

char[] density = new char[] {' ', '.', 'x', 'W'};

for(int c = 0; c < testCases; c++)
{
for(int i = 0; i < 10; i++)
dna[i] = scanner.nextInt();

dish = new int[42];
dish[20] = 1;

for(int r = 0; r < 50; r++)
{
int[] tmp = new int[42];

for(int d=1; d <= 40; d++)
{
output.append(density[dish[d]]);
tmp[d] = dna[dish[d-1]+dish[d]+dish[d+1]];
}

dish = tmp;

output.append("\n");
}
output.append("\n");
}
System.out.print(output.deleteCharAt(output.length()-1));
}
}