Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #define N 200001
- using namespace std;
- ///2650
- ifstream fin(".in");
- ofstream fout(".out");
- int n, v[N],i,j,x, poz;
- bool st[N]; ///0 daca e si 1 daca nu este
- int main()
- {
- cin>>n;
- for(i=0; i<n; i++)cin>>v[i];
- ///am presuspus ca toate elem sunt in stiva
- for(i=0; i<n; i++)
- {
- cin>>x;
- j=poz;
- if(st[x]==0)
- {
- j=poz;
- while(v[j]!=x)
- {
- st[v[j]]=1;///stergere din stiva
- ++j;
- }
- cout<<j-poz+1<<" ";
- poz=j+1;
- }
- else cout<<0<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement