0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-25 17:32:01 +00:00
OI-codes/S2OJ/161/data/val.cpp

53 lines
891 B (Stored with Git LFS)
C++

#include <bits/stdc++.h>
#include "testlib.h"
using namespace std;
const int MAXN = 505;
const int LIM = 1e6;
std::vector<int> G[MAXN];
std::unordered_set<int> s;
int vis[MAXN];
int n,m,k;
inline void addedge(int u,int v)
{
G[u].push_back(v);
G[v].push_back(u);
}
void dfs(int x)
{
vis[x]=1;
for(int y : G[x]) if(!vis[x]) dfs(y);
}
int main(int argc, char *argv[])
{
registerValidation();
n=inf.readInt(1,MAXN); inf.readSpace();
m=inf.readInt(1,MAXN); inf.readSpace();
k=inf.readInt(1,min(n,10)); inf.readEoln();
for(int i=1,u,v; i<=m; ++i)
{
u=inf.readInt(1,n); inf.readSpace();
v=inf.readInt(1,n); inf.readSpace();
inf.readInt(1,LIM); inf.readEoln();
addedge(u,v);
}
for(int i=1; i<=k; ++i)
{
s.insert(inf.readInt(1,n));
if(i!=k) inf.readSpace();
}
inf.readEoln();
ensuref(((int)s.size()==k),"Repeated key nodes found!");
inf.readEof();
return 0;
}