Tarango

AAA

Dec 4th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class acm {
  3.     public static int N,M;
  4.     public static Obj ary[][] = new Obj[20][20];
  5.     public static int order[] = new int[20];
  6.     public static void main(String[] args) {
  7.         Scanner kb = new Scanner(System.in);
  8.         N = kb.nextInt();
  9.         M = kb.nextInt();
  10.         for(int i = 0;i<N;i++){
  11.             for(int j = 0;j<M;j++){
  12.                 ary[i][j] = new Obj();
  13.                 ary[i][j].id = kb.nextInt();
  14.             }
  15.         }
  16.         call(0);
  17.     }
  18.    
  19.     public static void call(int cur){
  20.         if(cur == N){
  21.             //Reached Final State;
  22.             for(int i = 0;i<N;i++){
  23.                 int idx = order[i];
  24.                 System.out.print(ary[i][idx].id);
  25.             }
  26.             System.out.println();
  27.             return;
  28.         }
  29.         for(int i = 0;i<M;i++){
  30.             order[cur] = i;
  31.             call(cur+1);
  32.         }
  33.     }
  34. }
  35.  
  36. class Obj{
  37.     int id;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment