• hdu 6165


    虽然题解上说缩点然后判断入度就可以了,然后比赛的时候瞎暴力过了。

    #include <iostream>
    #include <cstring>
    #include <string>
    #include <queue>
    #include <vector>
    #include <map>
    #include <set>
    #include <stack>
    #include <cmath>
    #include <cstdio>
    #include <algorithm>
    #include <iomanip>
    #define N 1010
    #define LL __int64
    #define inf 0x3f3f3f3f
    #define lson l,mid,ans<<1
    #define rson mid+1,r,ans<<1|1
    #define getMid (l+r)>>1
    #define movel ans<<1
    #define mover ans<<1|1
    using namespace std;
    const LL mod = 1000000007;
    int n, m;
    bool flag[N][N];
    int cnt;
    vector<int> mapp[N];
    bool vis[N];
    void dfs(int u) {
        for (int i = 0; i < mapp[u].size(); i++) {
            int v = mapp[u][i];
            if (!vis[v]) {
                flag[cnt][v] = true;
                flag[v][cnt] = true;
                vis[v] = true;
                dfs(v);
            }
        }
    }
    void solve(int u) {
        memset(vis, false, sizeof(vis));
        vis[u] = true;
        cnt = u;
        dfs(u);
        flag[u][u] = 1;
    }
    void init() {
        for (int i = 0; i <= n; i++) {
            mapp[i].clear();
        }
        memset(flag, false, sizeof(flag));
    }
    int main() {
        cin.sync_with_stdio(false);
        int T;
        int a, b;
        cin >> T;
        while (T--) {
            cin >> n >> m;
            init();
            for (int i = 0; i < m; i++) {
                cin >> a >> b;
                mapp[a].push_back(b);
            }
            for (int i = 1; i <= n; i++) {
                solve(i);
            }
            cnt = 0;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    if (flag[i][j] == false) {
                        cnt = 1;
                    }
                }
            }
            if (!cnt) {
                cout << "I love you my love and our love save us!" << endl;
            }
            else {
                cout << "Light my fire!" << endl;
            }
        }
        return 0;
    }
  • 相关阅读:
    hdu 5015
    hdu 2276
    hdu 6197 array array array LIS
    poj 3070
    codefroce 854 A.Fraction
    sql数据库发布、订阅同步方式操作
    python排序(冒泡、直接选择、直接插入等)
    忘记mysql数据库密码时进行修改方法
    Word中图片自动编号且与文中引用的编号对应
    解决电脑本地网络连接显示红叉又可上网问题
  • 原文地址:https://www.cnblogs.com/z1141000271/p/7416463.html
Copyright © 2020-2023  润新知