希望更丰富的展现?使用[Markdown](https://www.luogu.org/wiki/show?name=%E5%B8%AE%E5%8A%A9%EF%BC%9Amarkdown)
(文化之旅不是瞎搞题吗)
by crpboy @ 2019-03-15 15:48:11
不使用Markdown?不希望更丰富的展现
by dead_X @ 2019-03-15 15:48:12
希望更丰富的展现?使用markdown
by 彩虹猫 @ 2019-03-15 15:50:24
希望更丰富的展现?使用[Markdown](https://www.luogu.org/wiki/show?name=%E5%B8%AE%E5%8A%A9%EF%BC%9Amarkdown)
by 我惠美如画 @ 2019-03-15 15:50:39
@[方家(rby)](/space/show?uid=146711) 这道题有问题,快孤立它
by wwlw @ 2019-03-15 15:55:15
不是一道错题吗。。。
by zylll @ 2019-03-15 15:55:29
这什么水题
by ecnerwaIa @ 2019-03-15 15:55:42
```c
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
vector< pair <int ,int > >va[3000];
int in()
{
char ch; int x=0,f=1;
while(!isdigit(ch=getchar()))(ch=='-')&&(f=-f);
while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
return x*f;
}
int n,k,m,s,t;
int ans=1e6;
bool done[3000];
int cul[3000];
int pai[120][120];
int xue[3000];
bool v;
bool check(int to,int cnt)
{
for(int i=1;i<=cnt;i++)
{
if(pai[cul[to]][xue[i]])
return false;
if(cul[to]==xue[i])
return false;
}
return true;
}
void dfs(int front,int ansl,int cnt)
{
if(ansl>ans)
return;
if(front==t)
{
v=1;
ans=min(ans,ansl);
return;
}
for(int i=0;i<va[front].size();i++)
{
int to=va[front][i].first;
int dis=va[front][i].second;
if(check(to,cnt)&&!done[to])
{
xue[cnt+1]=cul[to];
done[to]=1;
dfs(to,ansl+dis,cnt+1);
done[to]=0;
}
}
}
int main()
{
// freopen("b.in","r",stdin);
// freopen("b.out","w",stdout);
n=in();
k=in();
m=in();
s=in();
t=in();
for(int i=1;i<=n;i++)
cul[i]=in();
int x;
for(int i=1;i<=k;i++)
for(int j=1;j<=k;j++)
{
pai[i][j]=in();
}
for(int i=1;i<=m;i++)
{
int u,v,val;
u=in();
v=in();
val=in();
va[u].push_back(make_pair(v,val));
va[v].push_back(make_pair(u,val));
}
xue[1]=cul[s];
done[s]=1;
if(pai[t][s])
{
cout<<"-1";
return 0;
}
dfs(s,0,1);
if(!v)
cout<<"-1";
else
cout<<ans;
//fclose(stdin);
// fclose(stdout);
return 0;
}
```
by 方家(rby) @ 2019-03-15 16:01:16
@[方家(rby)](/space/show?uid=146711) 这道题有问题,快孤立它
by 142857cs @ 2019-03-15 16:29:55