原题链接:2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)

Pants On Fire

Donald and Mike are the leaders of the free world and haven’t yet (after half a year) managed to start a nuclear war. It is so great! It is so tremendous!

Despite the great and best success of Donald’s Administration, there are still a few things he likes to complain about.

The Mexican government is much smarter, much sharper, and much more cunning. And they send all these bad hombres over because they don’t want to pay for them. They don’t want to take care of them.

Donald J. Trump, First Republican Presidential Debate, August 6, 2015

He also frequently compares Mexicans to other bad people (like Germans, since they are exporting so many expensive cars to the US). Due to the tremendous amount of statements   he has made (mostly containing less than 140 characters ...) the “Fake-News” New York Telegraph (NYT) has to put in a lot of effort to clarify and comment on all the statements of Donald. To check a statement, they have a list of facts they deem to be true and classify Donald’s statements into three groups: real facts (which are logical conclusions from their list of true facts), exaggerations (which do not follow, but are still consistent with the papers list of facts), and alternative facts (which contradict the knowledge of the newspaper).

They have asked you to write a program helping them to classify all of Donald’s statements – after all it is hard for a journalist to go through them all and check them all, right?

Input

The input consists of:

    • one line containing two integers n and m, where

      • n (1 n 200) is the number of facts deemed true by the NYT;
      • m (1 m 200) is the number of statements uttered by the Donald.
    • n lines each containing a statement deemed true by the NYT.
    • m lines each containing a statement uttered by the Donald.

All statements are of the form a are worse than b, for some strings a and b, stating that a is (strictly) worse than b. The strings a and b are never identical. Both a and b are of length between 1 and 30 characters and contain only lowercase and uppercase letters of the English alphabet.

Note that Donald’s statements may contain countries that the NYT does not know about. You may assume that worseness is transitive and that the first n lines do not contain any contradictory statement. Interestingly, Donald’s press secretary (Grumpy Sean) has managed to convince him not to make up countries when tweeting, thus the input mentions at most 193 different countries.

Output

For every of the m statements of Donald output one line containing

  • Fact if the statement is true given the n facts of the NYT
  • Alternative Fact if the inversion of the statement is true given the n facts of the NYT
  • Pants on Fire if the statement does not follow, but neither does its inverse.

Sample Input 1

4 5

Mexicans are worse than Americans

Russians are worse than Mexicans

NorthKoreans are worse than Germans

Canadians are worse than Americans

Russians are worse than Americans

Germans are worse than NorthKoreans

NorthKoreans are worse than Mexicans

NorthKoreans are worse than French

Mexicans are worse than Canadians

Sample Output 1

Fact

Alternative Fact

Pants on Fire

Pants on Fire

Pants on Fire

求个传递闭包就能AC,拷贝到了东庆巨巨的代码,顺便学了点用map把串转化成下标;话说这个闭包写的真漂亮

#include <bits/stdc++.h>
using namespace std; map <string, int> data; const int MAX = 500;
int tot; int get( string str )
{
if( data.count(str) ) return data[str];
tot = data.size();
data[str] = ++tot;
return data[str];
} int edge[MAX][MAX]; int main()
{
int n, m;
cin >> n >> m;
while( n-- )
{
int u, v;
string str;
cin >> str;
u = get(str);
cin >> str;
cin >> str;
cin >> str;
cin >> str;
v = get(str);
edge[u][v] = 1;
}
for( int c = 1; c <= tot; c++ )
for( int a = 1; a <= tot; a++ )
for( int b = 1; b <= tot; b++ )
edge[a][b] |= edge[a][c] && edge[c][b];
while( m-- )
{
int u, v;
string str;
cin >> str;
u = get(str);
cin >> str;
cin >> str;
cin >> str;
cin >> str;
v = get(str); if( edge[u][v] ) printf("Fact\n");
else if( edge[v][u] ) printf("Alternative Fact\n");
else printf("Pants on Fire\n");
}
return 0;
}

Gym-101873D-Pants On Fire(闭包)的更多相关文章

  1. Gym 101873D - Pants On Fire - [warshall算法求传递闭包]

    题目链接:http://codeforces.com/gym/101873/problem/D 题意: 给出 $n$ 个事实,表述为 "XXX are worse than YYY" ...

  2. 【闭包】Pants On Fire

    Pants On Fire 题目描述 Donald and Mike are the leaders of the free world and haven’t yet (after half a y ...

  3. Pants On Fire(链式前向星存图、dfs)

    Pants On Fire 传送门:链接  来源:upc9653 题目描述 Donald and Mike are the leaders of the free world and haven't ...

  4. (寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)

    layout: post title: (寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017) au ...

  5. gym 101873

    题还没补完 以下是牢骚:删了 现在只有六个...太恐怖了,我发现四星场我连300人的题都不会啊. C:最短路加一维状态就好了叭..嗯,一开始没看到输出的那句话 那个  "."也要输 ...

  6. 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017) Solution

    A. Drawing Borders Unsolved. B. Buildings Unsolved. C. Joyride Upsolved. 题意: 在游乐园中,有n个游玩设施,有些设施之间有道路 ...

  7. 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)

    A Drawing Borders 很多构造方法,下图可能是最简单的了 代码: #include<bits/stdc++.h> using namespace std; ; struct ...

  8. Multi-label && Multi-label classification

    Multi-label classification with Keras In today’s blog post you learned how to perform multi-label cl ...

  9. The German Collegiate Programming Contest 2017

    B - Building 给一个m各面的多边形柱体,每一侧面有n*n个格子,现在对这些格子染色,看有多少种方式使得多面柱体无论如何旋转都不会与另一个一样. #include <bits/stdc ...

随机推荐

  1. Template7学习记录

    来源:http://idangero.us/template7/#.V2iXqJGF6Ul 测试用json数据: var jsonData = { people: [ { firstName: 'Jo ...

  2. Qt的安装和使用中的常见问题(详细版)

    对于太长不看的朋友,可参考Qt的安装和使用中的常见问题(简略版). 目录 1.引入 2.Qt简介 3.Qt版本 3.1 查看安装的Qt版本 3.2 查看当前项目使用的Qt版本 3.3 查看当前项目使用 ...

  3. mysql中timestamp简单用法

    该时间字段有比较特殊的地方,显示内容datetime字段一样.当取值为null或者不赋值时,显示当前系统时间,然后在其他地区读取的时候会根据当地的时间转换成当地的系统时间.

  4. 界面编程与视图(View)组件

    1.视图组件与容器组件 Android应用绝大部分UI组件都放在Android.widget包及其子包.android.view包及其子包中,其所有UI组件都继承了view类,view组件代表一个空白 ...

  5. css控制同一个页面的两个表格,一个显示有边框线,而另一个没边框线

    不显示边框的:<table border="0" cellspacing="0"  cellpadding="" ><tr ...

  6. FCLK、HCLK、PCLK

    一,PLL    S3C2440 CPU主频可达400MHz,开发板上的外接晶振为12M,通过时钟控制逻辑的PLL(phase locked loop,锁相环电路)来倍频这个系统时钟.2440有两个P ...

  7. 测试用数据库表设计和SessionFactory

    本篇为struts-2.5.2和spring-3.2.0以及hibernate-4.2.21的整合开篇. 一.测试的数据库表. 用户.角色和权限关系表.数据库是Mysql5.6.为了考虑到一些特殊数据 ...

  8. 用 pyqt4 编写的一个翻译小工具

    有时候我们在开发时遇到一些陌生的英文单词或者不容易看出某些长句的中文意思时该怎么办呢?打开桌面上的翻译软件?打开浏览器里收藏着的翻译网址或者直接贴上百度的搜索框去查?这些方法固然可以,还很常见,但如果 ...

  9. JavaScript实现的3D球面标签云效果

    这个效果都是由 FLASH 实现的,能不能由 JavaScript 实现呢? 我们也十分喜欢这个效果,就花了一些时间写出来了,如图所示: 效果预览点这里:http://www.miaov.com/mi ...

  10. Jenkins的多个任务并串联参数传递

    Jenkins的多个任务并串联参数传递 Parameterized Trigger Plugin插件可以使多个job连接的时候可以传递一些job相关的参数信息. 1.Parameterized Tri ...