View Code of Problem 7

#include<iostream>
using namespace std;
 
const int MAX = 100000;
int map1[MAX];
int map2[MAX];
 
int main(){
  int t, blank;
  cin >> t;
  for(int i = 0; i < t; ++i){
  	int n;
    	cin >> n;
    for(int j = 0; j < n; j++){
    	int a,b;
      	char c;
      	cin >> a >> c >> b;
      	map1[a] = b;
      	map2[b] = a;
    }
    int m;
    cin >> m;
    for(int j = 0; j < m; j++){
    	int q;
      	cin >> q;
      	if(map1[q] != 0){
        	cout << map1[q] << endl;
    	}else if(map2[q] != 0){
        	cout << map2[q] << endl;
        }else{
        	cout << "UNKNOW" << endl;
        }
    }
    if(i < t - 1){
    	cout << endl;
    }
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 7