文章

68

粉丝

691

获赞

26

访问

578.3k

头像
spfa
P1061
发布于2020年5月10日 08:40
阅读数 7.5k

 逐对spfa水过

#include<iostream>
#include<cstdio>
#include<string>
#include<string.h>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
#include<set>
using namespace std;

#define ll long long
#define vec vector<ll>
#define MAX 1005
#define inf 0x3fffffff
#define P pair<ll,ll>

vec G[MAX];
ll vis[MAX];

int main() {
	ll N, a, b, c;
	while (cin >> N) {
		ll p = 0; for (int i = 0; i < MAX; i++)G[i].clear();
		for (int i = 1; i <= N; i++) {
			cin >> a >> c; p = max(p, c);
			for (int j = 1; j < a - 1; j++) {
				cin >> b; p = max(p, b);
				G[c].push_back(b);
			}
		}
		for (int i = 0; i < N; i++) {
			cin >> a >> b;
			memset(vis, 0, sizeof(vis)); 
			vis[a] = 1; ll sign = 0;
			queue<ll> q; q.push(a);
			while (!q.empty()) {
				ll v = q.front(); q.pop();
				if (v == b) { sign = 1; break; }
				for (int...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发