You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
///*
// * map02.cpp
// *
// * Created on: May 7, 2024
// * Author: 28032
// */
//
////1.使用set将图储存
////2.用数组将BFS序列储存
////3.采用BFS, 从头开始检验序列的正确性, 取出一个数, 访问它的所有邻接点, 看是否有与序列的下一个点相同的
////如果有相同的, 就将该点压入队列, 并在G中删除该邻接点, 如果没有, 返回false; 当这个数的所有邻接点都删完后, 再在队列中取一个数重复操作
//
//#include <iostream>
//#include <set>
//#include <queue>
//
//using namespace std;
//
//set<int>* G;
//int* l;
//int n;
//
//bool BFS(void)
//{
// queue<int> q;
//
// int i = 2; //表示检查到序列的第几个数
//
// q.push(1);
//
// while(!q.empty())
// {
// int t = q.front();
// q.pop();
//
// while(!G[t].empty())
// {
// if(G[t].find(l[i]) == G[t].end())
// return false;
//
// q.push(l[i]);
// G[t].erase(l[i]);
// G[l[i]].erase(t);
// i++;
// }
// }
//
// return true;
//}
//
//int main()
//{
// cin>>n;
// G = new set<int>[n+1];
// l = new int[n+1];
//
// for(int i = 1;i < n;i++)
// {
// int a,b;
// cin>>a>>b;
// G[a].insert(b);
// G[b].insert(a);
// }
//
// for(int i = 1;i <= n;i++)
// {
// int a;
// cin>>a;
// l[i] = a;
// }
//
// BFS()?cout<<"Yes":cout<<"No";
//
//
// return 0;
//}