• map,实现技巧,id


    cf

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<algorithm>
     4 #include<vector>
     5 #include<cstring>
     6 #include<map>
     7 #include<set>
     8 #include<cmath>
     9 #include<queue>
    10 #include<bitset>
    11 #include<utility>
    12 #include<functional>
    13 #include<iomanip>
    14 #include<sstream>
    15 #include<ctime>
    16 #include<cassert>
    17 #define A first
    18 #define B second
    19 #define mp make_pair
    20 #define pb push_back
    21 #define pw(x) (1ll << (x))
    22 #define sz(x) ((int)(x).size())
    23 #define all(x) (x).begin(),(x).end()
    24 #define rep(i,l,r) for(int i=(l);i<(r);i++)
    25 #define per(i,r,l) for(int i=(r);i>=(l);i--)
    26 #define FOR(i,l,r) for(int i=(l);i<=(r);i++)
    27 #define eps 1e-9
    28 #define PIE acos(-1)
    29 #define cl(a,b) memset(a,b,sizeof(a))
    30 #define fastio ios::sync_with_stdio(false);cin.tie(0);
    31 #define lson l , mid , ls
    32 #define rson mid + 1 , r , rs
    33 #define ls (rt<<1)
    34 #define rs (ls|1)
    35 #define INF 0x3f3f3f3f
    36 #define lowbit(x) (x&(-x))
    37 #define sqr(a) a*a
    38 #define ll long long
    39 #define ull unsigned long long
    40 #define vi vector<int>
    41 #define pii pair<int, int>
    42 #define dd(x) cout << #x << " = " << (x) << ", "
    43 #define de(x) cout << #x << " = " << (x) << "
    "
    44 #define endl "
    "
    45 using namespace std;
    46 //**********************************
    47 int n,m;
    48 map<string,int>ids;
    49 const int maxn=507;
    50 //**********************************
    51 inline int id(string s)
    52 {
    53     if(ids.count(s))return ids[s];
    54     return ids[s]=sz(ids);
    55 }
    56 int f[maxn][maxn];
    57 //**********************************
    58 int main()
    59 {
    60     string a,c,d,e,b;
    61     cin>>n>>m;
    62     FOR(i,1,n){
    63         cin>>a>>c>>d>>e>>b;
    64         f[id(a)][id(b)]=1;
    65     }
    66     int g=sz(ids);
    67     FOR(k,1,g)FOR(i,1,g)FOR(j,1,g)f[i][j]=f[i][j]||(f[i][k]&&f[k][j]); 
    68     FOR(i,1,m){
    69         cin>>a>>c>>d>>e>>b;
    70 //        cout<<a<<c<<d<<e<<b<<endl;
    71 //        de(!ids.count(a)||!ids.count(b));
    72 //        de(f[id(a)][id(b)]);
    73         if(!ids.count(a)||!ids.count(b))cout<<"Pants on Fire"<<endl;
    74         else if(f[id(a)][id(b)])cout<<"Fact"<<endl;
    75         else if(f[id(b)][id(a)])cout<<"Alternative Fact"<<endl;
    76         else cout<<"Pants on Fire"<<endl;
    77     }
    78     return 0;
    79 }
    View Code
  • 相关阅读:
    你用过宏##粘贴函数,然后用函数指针查找执行吗?今天就给你说道说道
    c++nullptr(空指针常量)、constexpr(常量表达式)
    c++bind函数使用
    WordPress高亮代码插件enlighter自定义CSS
    终于有人把云计算、大数据和人工智能讲明白了!
    14. vue源码入口+项目结构分析
    13. Vue CLI脚手架
    12. Vue搭建本地服务
    11. webpack配置Vue
    10. vue之webpack打包原理和用法详解
  • 原文地址:https://www.cnblogs.com/klaycf/p/9642960.html
Copyright © 2020-2023  润新知