题目链接:
题解(1001):
1 #include2 using namespace std; 3 4 int a[1005], b[1005], ans[1005]; 5 6 int main(){ 7 int T; 8 scanf("%d", &T); 9 while(T--){10 int n, c;11 scanf("%d%d", &n, &c);12 for(int i = 0; i < n; i++) scanf("%d", &a[i]);13 for(int i = 0; i < n; i++) scanf("%d", &b[i]);14 memset(ans, -1, sizeof(ans));15 for(int i = 0; i < n; i++){16 for(int j = 0; j < n; j++){17 if(b[j] != -1 && a[i] == b[j]){18 ans[i] = j+1;19 b[j] = -1;20 break;21 }22 }23 }24 //for(int i = 0; i < n; i++) printf("%d ", ans[i]); printf("\n");25 while(c--){26 int l, r;27 scanf("%d%d", &l, &r);28 sort(ans+l-1, ans+r);29 //printf("l:%d, r:%d\t:", l ,r);30 //for(int i = 0; i < n; i++) printf("%d ", ans[i]); printf("\n");31 }32 int f = true;33 for(int i = 0; i < n; i++){34 if(ans[i] != i+1){35 f = false;36 break;37 }38 }39 if(f == true) puts("Yes");40 else puts("No");41 }42 43 return 0;44 }