View Code of Problem 7

#include <stdio.h>
#include <stdlib.h>

int a[100005];

int main()
{
	int t, n;
	scanf("%d", &t);
	int c = 0;
	while (t--)
	{
		if (c != 0)
		{
			putchar('\n');
		}
		c++;
		for (int i = 0; i < 100005; i++)
		{
			a[i] = -1;
		}
		scanf("%d", &n);
		int s, t;
		for (int i = 0; i < n; i++)
		{
			scanf("%d=%d", &s, &t);
			a[s] = t;
			a[t] = s;
		}
		int m;
		scanf("%d", &m);
		while (m--)
		{
			scanf("%d", &s);
			if (s < 0 || s > 100000 || a[s] == -1)
				puts("UNKNOW");
			else printf("%d\n", a[s]);
		}
	}
}

Double click to view unformatted code.


Back to problem 7