#include<iostream>
#include<cstdio>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
#include<iterator>
#include<assert.h>
using namespace std;
#define INF (1<<63)-1
#define SET(a) memset(a,-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset(a,0,sizeof(a))
#define PB push_back
#define FOR(i,n) for(int i = 0;i<n;i++)
#define PI acos(-1.0)
#define EPS 1e-9
#define MP(a,b) make_pair(a,b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
#define LL long long
#define MOD 1000000007
#define S(a) scanf("%d",&a)
#define P(a) printf("%d",a)
#define KS printf("Case %d: ",kk++)
#define NL printf("\n")
#define MX 100000
int main()
{
int t,kk=1,n,l,c,sl,arr[30],arr2[30],move,pos,tmp;
string s;
while(cin>>n)
{
FOR(i,n)
cin>>arr[i];
FOR(i,n)
cin>>arr2[i];
move=0;
FOR(i,n)
{
for(int j=i;j<n;j++)
if(arr2[i]==arr[j])
{
pos=j;
break;
}
for(int j=pos;j>i;j--)
{
arr[j]=arr[j-1];
move++;
}
}
cout<<move<<endl;
}
return 0;
}
Can u explain why u do this???
ReplyDeleteI cant understood the problem !!!!!!!!!