#include<stdio.h> #include <string.h> #include <math.h> int main(){ int t; int n; int m,h; int i,j,k; int mask; int a[1000][2]; //int b[1000]; scanf("%d",&t); for(k=0;k<t;k++){ scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d=%d",&a[i][0],&a[i][1]); } scanf("%d",&m); //for(j=0;j<m;k++){ //scanf("%d",&b[j]); //} for(j=0;j<m;j++){ scanf("%d",&h); mask=0; for(i=0;i<n;i++){ if(h==a[i][0]){ printf("%d\n",a[i][1]); mask=1; break; } else if(h==a[i][1]){ printf("%d\n",a[i][0]); mask=1; break; } } if(mask==0) printf("UNKNOW\n"); } printf("\n"); } return 0; } |
Double click to view unformatted code.