比赛 平凡的题目 评测结果 WWWWW
题目名称 平凡的皮卡丘 最终得分 0
用户昵称 pppoooiiizzy 运行时间 0.002 s
代码语言 C++ 内存使用 1.08 MiB
提交时间 2015-11-03 10:25:32
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<queue>
#include<vector>
#include<set>
#include<cstring>
#include<string>
#include<stack>

const int maxn = 40000 + 5;
using namespace std;

#define rep(i, j, k) for(int i = j; i <= k; i++)
#define drep(i, j, k) for(int i = j; i >= k; i--)
#define INF 0x3fffffff
#define LL long long

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}

struct poi {
    int to, dist;
};

vector<poi>G[maxn];
int vis[maxn], m, n, Ar, Sa, La, Ca, d[maxn], cnt, tot, ans = INF, sum;
vector<int>T;

void add(int from, int to, int dist1, int dist2)
{
    G[from].push_back((poi){to, dist1});
    G[to].push_back((poi){from, dist2});
}

void init()
{
    n = read(), m = read();
    rep(i, 1, m) {
        Ar = read(), Sa = read(), La = read(), Ca = read();
        add(Ar, Sa, La, Ca);
    }
}

bool bfs(int x)   // zi huan
{
    queue<int>q;
    memset(vis, 0, sizeof(vis));
    q.push(x);
    vis[x] = 0;
    while(!q.empty()) {
        int k = q.front(); q.pop();
        vis[k]++;
        for(int i = 0; i < G[k].size(); i++) {
            poi &e = G[k][i];
            if( vis[e.to] <= 2)
                q.push(e.to);
        }
        T.push_back(k);
    }
    if(vis[x] >= 1) return true;
    else return false;
}

void HHH(int i)
{
    for(int j = 0; j < G[T[i]].size(); j++) if( G[T[i]][j].to == T[i + 1]) {sum += G[T[i]][j].dist;}
}
int main()
{
    freopen("both.in", "r", stdin);
    freopen("both.out", "w", stdout);
    /*init();
    if( !bfs(1) ) cout<<-1<<endl;
    else {
        for(int i = 0; i < T.size(); i += 3) {
            sum = 0;
            if(T[i] != T[i + 1] && T[i + 1] != T[i + 2] && T[i] != T[i + 2]) {
                HHH(i);
            }
            if(sum)
            ans = min(ans, sum);
        }
        cout<<ans<<endl;
    }*/
    cout<<-1<<endl;
}