Valid BFS? CodeForces - 1037D The BFS algorithm is defined as follows. Consider an undirected graph with vertices numbered from 11 to nn. Initialize qqas a new queue containing only vertex 1, mark the vertex 1 as used. Extract a vertex vv from the he…
题意 题目链接 Sol 非常妙的一道题.. 可以这样想,在BFS序中较早出现的一定是先访问的,所以把每个点连出去的边按出现的前后顺序排个序 看一下按顺序遍历出来的序列与给出的是否相同就行了 #include<bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 10; inline int read() { char c = getchar(); int x = 0, f = 1; while(c < '0' || c &g…
题目链接: C. Three States time limit per test 5 seconds memory limit per test 512 megabytes input standard input output standard output The famous global economic crisis is approaching rapidly, so the states of Berman, Berance and Bertaly formed an allia…