1073B. Vasya and Books

1073B. Vasya and Books

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2*100000 + 5;
int n,s[maxn],t[maxn],vis[maxn],res[maxn];
int main()
{
    // freopen("data.in","r",stdin);
    // freopen("data.out","w",stdout);
    scanf("%d",&n);
    for(int i = 0; i < n; i++) scanf("%d",&s[i]);
    for(int i = 0; i < n; i++) scanf("%d",&t[i]);
    int j = 0;
    for(int i = 0; i < n; i++){
        int cnt = 1;
        if(vis[t[i]]) cnt = 0;
        else{
            while(s[j] != t[i]){
                vis[s[j]] = 1;
                cnt++; j++;
            }
            j++;
        }
        res[i] = cnt;
    }
    for(int i = 0; i < n-1; i++) printf("%d ",res[i]);
    printf("%d\n",res[n-1]);
    return 0;
}

 

posted @ 2018-10-29 22:34  ACLJW  阅读(107)  评论(0编辑  收藏  举报