This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner scn = new Scanner(System.in); | |
int n=scn.nextInt(); | |
while(n--!=0){ | |
int arr[][]=new int[4][4]; | |
for(int i=0;i<4;i++){ | |
scn.next(); | |
while(true){ | |
int num=scn.nextInt(); | |
if(num==0) | |
break; | |
else | |
arr[i][num-1]=1; | |
} | |
} | |
int count=0; | |
for(int i=0;i<4;i++){ | |
if(arr[0][i]==1) | |
continue; | |
for(int j=0;j<4;j++){ | |
if(arr[1][j]==1) | |
continue; | |
for(int k=0;k<4;k++){ | |
if(arr[2][k]==1) | |
continue; | |
for(int l=0;l<4;l++){ | |
if(arr[3][l]==1) | |
continue; | |
else{ | |
int temp[]=new int[4]; | |
temp[i]=1;temp[j]=1;temp[k]=1;temp[l]=1; | |
if(temp[0]+temp[1]+temp[2]+temp[3]==4){ | |
if(count==0) | |
System.out.println("ABCD"); | |
System.out.println((i+1)+""+(j+1)+""+(k+1)+""+(l+1)); | |
count++; | |
} | |
} | |
} | |
} | |
} | |
} | |
if(count==0) | |
System.out.println("No Solution"); | |
System.out.println(); | |
} | |
} | |
/*題目:C_AR61-易 配對 | |
作者:1010 | |
時間:西元 2017 年 4 月 7日*/ | |
} |
沒有留言:
張貼留言