#include<iostream> #include<stdio.h> #include<bits/stdc++.h> #include<algorithm> #include<cmath> #include<cstring> #include<cstdlib> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int times; cin>>times; cout<<endl; while(times--){ int n,flag=0,m; int num[100001]={0}; cin>>n; for(int i=1;i<=n;i++) { flag=0; string str,sa,sb; cin>>str; for(int j=0;j<str.length();j++) { if(str[j]=='=') { flag=1;continue; } if(flag) sb+=str[j]; else sa+=str[j]; } int aa=atoi(sa.c_str()); int bb=atoi(sb.c_str()); num[aa]=bb; num[bb]=aa; } cin>>m; while(m--) { int cnt; cin>>cnt; if(num[cnt]>0) cout<<num[cnt]; else cout<<"UNKNOW"; if(m>=1) cout<<endl; } if(times>=1){ cout<<endl; cout<<endl; } } return 0; } |
Double click to view unformatted code.