#include <iostream>
#include <vector>
#include <bitset>
// #include <algorithm>
// #include <stack>
using namespace std;
vector<vector<int> > rules;
vector<int> plan(1001);
int flag=0;
int main(){
int n,m;
cin>>n>>m;
for(int i=0;i<m;i++){
int x,y;
cin>>x>>y;
rules.push_back({x,y});
}
for(int i=0;i<n;i++){
int x;
cin>>x;
plan[x]=i;
}
for(int i=0;i<m;i++){
if(plan[rules[i][0]]>plan[rules[i][1]]){
flag=1;
break;
}
}
if(flag)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
return 0;
}
#include <vector>
#include <bitset>
// #include <algorithm>
// #include <stack>
using namespace std;
vector<vector<int> > rules;
vector<int> plan(1001);
int flag=0;
int main(){
int n,m;
cin>>n>>m;
for(int i=0;i<m;i++){
int x,y;
cin>>x>>y;
rules.push_back({x,y});
}
for(int i=0;i<n;i++){
int x;
cin>>x;
plan[x]=i;
}
for(int i=0;i<m;i++){
if(plan[rules[i][0]]>plan[rules[i][1]]){
flag=1;
break;
}
}
if(flag)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
return 0;
}
Comments
Post a Comment