#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; int num[100001]; memset(num,-1,sizeof(num)); //cout<<num[3]<<"asd"<<endl; 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]=='=') { j++;flag=1; } if(flag==0) sa+=str[j]; else sb+=str[j]; } //cout<<sa<<" "<<sb<<endl; int aa=atoi(sa.c_str()); int bb=atoi(sb.c_str()); //cout<<aa<<" "<<bb; num[aa]=bb;//cout<<aa<<"=="<<bb<<endl; num[bb]=aa;//cout<<bb<<"=="<<aa<<endl; } int m; cin>>m; while(m--) { int cnt; cin>>cnt; if(num[cnt]!=-1) cout<<num[cnt]; else cout<<"UNKNOW"; if(m>1||times>=1) cout<<endl; } if(times>=1) cout<<endl; } return 0; } |
Double click to view unformatted code.