Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
651 B
2
Indexable
Never
#include<stdio.h>

int main()
{
    int n,m,a,b,pos=0,k,tmp;
    scanf("%d %d %d", &n, &m, &k);
    int seat[n+1];
    int stu[n+1];
    for(int i=1; i<=n; i++)
    {
        seat[i] = i;
        stu[i] = i;
    }

    for(int i=0; i<m; i++)
    {
        scanf("%d %d", &a, &b);

        tmp = seat[a];
        seat[a] = seat[b];
        seat[b] = tmp;

        stu[seat[a]] = a;
        stu[seat[b]] = b;
        
    }

    for(int i=0; i<k; i++)
    {
        scanf("%d", &pos);
        if(i!=k-1)
            printf("%d ", stu[pos]);
        else
            printf("%d\n", stu[pos]);
    }

    return 0;

}