标签:
#include<cstdio>
#include<deque>
using namespace std;
deque<int> q;
deque<int>::iterator itq;
int main(){
int n,m,k,tmp;
scanf("%d%d%d",&n,&m,&k);
for(int i = 0 ; i < k; ++i){
scanf("%d",&tmp);
q.push_back(tmp);
}
int ans = 0;
for(int i = 0 ; i < n; ++i){
for(int j = 0 ; j < m ; ++j){
scanf("%d",&tmp);
for(itq = q.begin();itq != q.end();++itq){
if(*itq == tmp){
ans += itq - q.begin() + 1;
q.erase(itq);
q.push_front(tmp);
break;
}
}
}
}
printf("%d\n",ans);
return 0;
}
[2016-04-25][codeforces][665B - Shopping]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/b97db9e5ba95d817330e211278d8fc47.html