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;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章