Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class acm {
- public static int N,M;
- public static Obj ary[][] = new Obj[20][20];
- public static int order[] = new int[20];
- public static void main(String[] args) {
- Scanner kb = new Scanner(System.in);
- N = kb.nextInt();
- M = kb.nextInt();
- for(int i = 0;i<N;i++){
- for(int j = 0;j<M;j++){
- ary[i][j] = new Obj();
- ary[i][j].id = kb.nextInt();
- }
- }
- call(0);
- }
- public static void call(int cur){
- if(cur == N){
- //Reached Final State;
- for(int i = 0;i<N;i++){
- int idx = order[i];
- System.out.print(ary[i][idx].id);
- }
- System.out.println();
- return;
- }
- for(int i = 0;i<M;i++){
- order[cur] = i;
- call(cur+1);
- }
- }
- }
- class Obj{
- int id;
- }
Advertisement
Add Comment
Please, Sign In to add comment