View Code of Problem 7

#include <iostream>
#include <cstring>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int a[100001]={0},x1,x2;
		fill(a,a+100001,-1);
		for(int i=0;i<n;i++){
			scanf("%d=%d",&x1,&x2);
			a[x1]=x2;
			a[x2]=x1;
		}
		int m;
		cin>>m;
		for(int i=0;i<m;i++){
			int temp;
			cin>>temp;
			if(a[temp]==-1){
				cout<<"UNKNOW"<<endl;
			}
			else{
				cout<<a[temp]<<endl;
			}
		}
		cout<<endl;
	}
} 

Double click to view unformatted code.


Back to problem 7