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

#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 = ;
int n, m;
bool flag[N][N];
int cnt;
vector<int> mapp[N];
bool vis[N];
void dfs(int u) {
for (int i = ; 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] = ;
}
void init() {
for (int i = ; 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 = ; i < m; i++) {
cin >> a >> b;
mapp[a].push_back(b);
}
for (int i = ; i <= n; i++) {
solve(i);
}
cnt = ;
for (int i = ; i <= n; i++) {
for (int j = ; j <= n; j++) {
if (flag[i][j] == false) {
cnt = ;
}
}
}
if (!cnt) {
cout << "I love you my love and our love save us!" << endl;
}
else {
cout << "Light my fire!" << endl;
}
}
return ;
}

hdu 6165的更多相关文章

  1. HDU 6165 FFF at Valentine(Tarjan缩点+拓扑排序)

    FFF at Valentine Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  2. 2017 Multi-University Training Contest - Team 9 1005&&HDU 6165 FFF at Valentine【强联通缩点+拓扑排序】

    FFF at Valentine Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  3. HDU 6165 FFF at Valentine

    题目大意:给出一个有向图,问你这个图中是否对于任意两点\(u,v\),都至少满足\(u\to v\)(\(u\)可到达\(v\),下同)或\(v\to u\)中的一个. 一看就是套路的图论题,我们先把 ...

  4. 2017ACM暑期多校联合训练 - Team 9 1005 HDU 6165 FFF at Valentine (dfs)

    题目链接 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any other ...

  5. HDU 6170 FFF at Valentine(强联通缩点+拓扑排序)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6165 题意:给你一个无环,无重边的有向图,问你任意两点,是否存在路径使得其中一点能到达另一点 解析:强 ...

  6. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  8. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  9. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

随机推荐

  1. 【Python】Python format 格式化函数(转帖)

    https://www.runoob.com/python/att-string-format.html Python2.6 开始,新增了一种格式化字符串的函数 str.format(),它增强了字符 ...

  2. 如何准备算法工程师面试,斩获一线互联网公司机器学习岗offer?

    原文:https://zhuanlan.zhihu.com/p/76827460?utm_source=wechat_session&utm_medium=social&utm_oi= ...

  3. OpenJudge计算概论-找出第k大的数

    /*================================================ 找出第k大的数 总时间限制: 1000ms 内存限制: 1000kB 描述 用户输入N和K,然后接 ...

  4. web框架性能点

    awesome-go-web-frameworks/README.md at master · speedwheel/awesome-go-web-frameworkshttps://github.c ...

  5. XListView实现上拉加载下拉刷新

    package com.loaderman.androiddemo; import android.content.Context; import android.util.AttributeSet; ...

  6. LeetCode_69. Sqrt(x)

    69. Sqrt(x) Easy Implement int sqrt(int x). Compute and return the square root of x, where x is guar ...

  7. (三)Centos之安装Xshell

    Xshell就是一个远程控制Centos的软件:(用XShell比较方便,试用的都知道,界面也人性化) 详细介绍请看 百度百科 我随便百度下载了一个中文版的 给下地址  http://pan.baid ...

  8. MySQL导入utf8编码的CSV文件

    首先,作为测试,我们在这里创建一个名为testdb的数据库,和一个名为test_table的表: create database if not exists testdb default charse ...

  9. [c++]C++关键字之friend

    re 1. C++关键字之friend; end 希望大家能把自己的所学和他人一起分享,不要去鄙视别人索取时的贪婪,因为最应该被鄙视的是不肯分享时的吝啬.---GOOD---

  10. Struts2中action接收中文参数为乱码解决方法

    老实说,中文乱码问题是每个程序员会经常遇到的问题,而且也是一个很头疼的问题.网上很多关于解决中文乱码的帖子,看几个之后你会发现大都是一样的.但是我们照着做,却还是无法解决乱码问题.我也是看了好多帖子, ...