Archivo: /home/misan/gcj/2009/C1/Welcome.java
Página 1 de 2
import java.util.*; import java.util.regex.*; class Alien { public static void main(String[] args) { Scanner in = new Scanner(System.in); int L = in.nextInt(); int D = in.nextInt(); String[] dictionary = new String[D]; int N = in.nextInt(); in.nextLine(); for(int i=0; i=0) if(map[x][y-1]<min) {min=map[x][y-1]; x1=x; y1=y-1; n=1;} // NORTH if(x-1>=0) if(map[x-1][y]<min) {min=map[x-1][y]; x1=x-1; y1=y; n=2;} // WEST if(x+1<W) if(map[x+1][y]<min) {min=map[x+1][y]; x1=x+1; y1=y; n=4;} // EAST if(y+1-1) next[x+y*W]=x1+y1*W; //next cell candidate, if any ... (or it's a sink) } for(int j=0;j<W*H; j++) if(out[j]<'a') { // not yet marked Stack l = new Stack(); int n = j; do {l.push(n); n=next[n]; } while(n!=-1); if(out[l.peek()]<'a') {for(int k : l) out[k]=basin; basin++;} // new basin, new color else {char c=out[l.peek()]; for(int k : l) out[k]=c;} // existing basin, same color } for(int j=0;j
Archivo: /home/misan/gcj/2009/C1/Welcome.java public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); in.nextLine(); for(int n=0; n
Página 2 de 2