zoj

weixin_33890499發表於2018-09-25
/*
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
#define N 100005
int num1[N];
int num2[N];
int num3[N];
int num4[N];
int num5[N];
int main() {
    int t;
    int n;
    cin >> t;
    while (t--)
    {
        scanf("%d", &n);
        for (int i = 0; i <n ; i++)
        {
            scanf("%d", &num1[i]);
            num3[num1[i]] = i;
        }
        for (int i = 0; i <n; i++)
        {
            scanf("%d", &num2[i]);
            num4[num2[i]] = i;
        }
        int a, b;
        int co = 0;
        for (int i = 1; i <= n; i++)
        {
            a = num3[i];
            b = num4[i];

            if (a ==b)
            {
                if (a == 0)
                {
                    num5[co++] = 0;
                }
                else 
                {
                    if (num1[a - 1] != num2[b-1])
                    num5[co++] =num1[a-4];
                    else
                    {
                        num5[co++] = num1[a - 1];
                    }
                }
            }
            else
            {
                if (a > b)
                {
                    num5[co++] = num1[b - 1];
                }
                else
                {
                    num5[co++] = num1[a- 1];
                }
            }
        }
        for (int i = 0; i < n; i++)
        {
            if (i == n - 1)
            {
                printf("%d", num5[i]);
            }
            else
            {
                printf("%d ", num5[i]);
            }
        }
        cout<< endl;
    }
    return 0;
}
*/