zoukankan      html  css  js  c++  java
  • CodeForces 707B Bakery

    枚举。

    枚举每一条边,如果发现边的一端$f[u]=1$,另一端$f[v]=0$,那么更新答案,取最小值就好了。

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<stack>
    #include<iostream>
    using namespace std;
    typedef long long LL;
    const double pi=acos(-1.0),eps=1e-6;
    void File()
    {
        freopen("D:\in.txt","r",stdin);
        freopen("D:\out.txt","w",stdout);
    }
    template <class T>
    inline void read(T &x)
    {
        char c = getchar(); x = 0;while(!isdigit(c)) c = getchar();
        while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar();  }
    }
    
    const int INF=0x7FFFFFFF;
    const int maxn=100010;
    int n,m,k;
    bool f[maxn];
    struct X{int u,v,w;}s[maxn];
    
    int main()
    {
        scanf("%d%d%d",&n,&m,&k);
        for(int i=1;i<=m;i++) scanf("%d%d%d",&s[i].u,&s[i].v,&s[i].w);
        for(int i=1;i<=k;i++)
        {
            int x; scanf("%d",&x);
            f[x]=1;
        }
        int ans=INF;
        for(int i=1;i<=m;i++)
        {
            if(f[s[i].u]&&f[s[i].v]) continue;
            if(!f[s[i].u]&&!f[s[i].v]) continue;
            ans=min(ans,s[i].w);
        }
        if(ans==INF) printf("-1
    ");
        else printf("%d
    ",ans);
        return 0;
    }
  • 相关阅读:
    sublime3快捷键汇总
    css3百叶窗轮播图效果
    分页特效
    百度评分标准
    兼容问题汇总
    随机彩票
    js 时间函数 及相关运算大全
    JS贪吃蛇游戏
    《Vim实用技巧》阅读笔记 --- 移动及跳转
    《深入理解Linux网络技术内幕》阅读笔记 --- 路由基本概念
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5836314.html
Copyright © 2011-2022 走看看