cin.sync_with_stdio(false);
用这句的时候只能cin || cout,scanf, printf会RE...TUT
题意:给出的姓或名字典序排序之后,与下面给出的下标的顺序是否相同。
#include<stdio.h>
#include<string>
#include<iostream>
#define N 100005
using namespace std;
string f[N], s[N];
int main()
{
int n;
cin.sync_with_stdio(false);
//ios::sync_with_stdio(0);
while(cin >> n)
{
for(int i = 1; i <= n; i++)
{
cin >> f[i] >> s[i];
if(f[i] < s[i])
swap(f[i], s[i]);
}
int lst, x;
cin >> lst;
string last = s[lst];
bool ff = 0;
for(int i = 1; i < n; i++)
{
cin >> x;
if(ff)
continue;
if(f[x] > last)
{
if(s[x] > last)
last = s[x];
else
last = f[x];
}
else
{
ff = 1;
}
}
if(ff)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
return 0;
}