首页 > 其他分享 >ZOJ 3960 What Kind of Friends Are You?(模拟)

ZOJ 3960 What Kind of Friends Are You?(模拟)

时间:2023-05-26 15:05:03浏览次数:49  
标签:tmp Kind 进制 int ZOJ cin tp ++ What


传送门

给你几个人,然后下i行对应的是回答出来第i个问题的人,最后询问回答出来了哪几个问题的是谁。

用一个map,存名字和数字,回答出的问题编号也转化为2进制,然后转化为10进制,这样的话每个人回答出的问题就对应的是一个数字,询问的时候也把2进制的串转化为10进制,这样的话比对就比较方便。对于每次询问,有唯一的人就输出名字,否则。。。嘿嘿嘿

#include <bits/stdc++.h>
using namespace std;
map<string,int>s;
string sx[220];
int x[220][220];
int main()
{
    //freopen("in.txt","r",stdin);
    cin.tie(0);
    cout.tie(0);
    int t,n,q,c,d;
    cin >> t;
    while(t--)
    {
        cin >> n >> q;
        memset(x,0,sizeof(x));
        s.clear();
        cin >> c;
        for(int i = 0;i < c; i++)
        {
            cin >> sx[i];
            s[sx[i]] = 0;
        }
        for(int i = 0;i < q; i++)
        {
            cin >> d;
            for(int j = 0;j < d; j++)
            {
                string tmp;
                cin >> tmp;
                s[tmp] += pow(2.0,i);
            }
        }
        while(n--)
        {
            int ans = 0,flag = 0;
            for(int i = 0;i < q; i++)
            {
                int tp;
                cin >> tp;
                if(tp == 1)
                {
//                    cout << i << " " << tp << " ";
                    ans += pow(2.0,i);
                }

            }
            string anss;
            for(int i = 0;i < c; i++)
            {
                if(s[sx[i]] == ans)
                {
                    anss = sx[i];
                    flag++;
                }
            }
            if(flag == 1)
            {
                cout << anss << endl;
                continue;
            }
            cout << "Let's go to the library!!" << endl;
        }
    }
    return 0;
}

 

标签:tmp,Kind,进制,int,ZOJ,cin,tp,++,What
From: https://blog.51cto.com/u_16131191/6356111

相关文章

  • ZOJ 3961 Let's Chat
    传送门给你A的区间和B的区间,然后问你重合的区间。答案就是求重合的区间长度-m+1的值。因为数据量不大,所以就让A的每个区间都对B的区间进行匹配,然后求和就可以了。这就是一种暴力。#include<bits/stdc++.h>usingnamespacestd;constintmaxn=150;typedefpair<int,int>pq;p......
  • ZOJ 3958 Cooking Competition
    传送门也没什么好说的,就根据题意说的写就完事儿了。#include<bits/stdc++.h>usingnamespacestd;intmain(){//freopen("in.txt","r",stdin);cin.tie(0);cout.tie(0);intt,ko,to;cin>>t;while(t--){intn;......
  • ZOJ 3959 Problem Preparation
    传送门根据题目描述写,对于每组给定的数据判断是否满足四个要求就可以了。#include<bits/stdc++.h>usingnamespacestd;intx[120];intmain(){//freopen("in.txt","r",stdin);cin.tie(0);cout.tie(0);intt;cin>>t;while(t--){......
  • What is doing __str__ function in Django?
    def str(self):isapythonmethodwhichiscalledwhenweuseprint/strtoconvertobjectintoastring.Itispredefined,howevercanbecustomised.Willseestepbystep.Supposebelowisourcode.classtopics():def__init__(self,topics):......
  • 支持复制粘贴word公式的KindEditor编辑器
    ​ 图片的复制无非有两种方法,一种是图片直接上传到服务器,另外一种转换成二进制流的base64码目前限chrome浏览器使用首先以um-editor的二进制流保存为例:打开umeditor.js,找到UM.plugins['autoupload'],然后找到autoUploadHandler方法,注释掉其中的代码。加入下面的代码://判断剪......
  • kindle7插件开发笔记[2]-使用Rust重写插件
    前言上一篇笔记:kindle7插件开发笔记[1]-在折腾中入门代码地址:https://gitee.com/qsbye/kindle-plugin-touch摘要用Rust语言重写在Kindle上显示图片的插件,初步实现了图片完整显示及自动刷新屏幕的功能.说明Kindle7的屏幕信息eips-i结果:Fixedframebufferinfoi......
  • whatweb----web指纹探测工具
    简介原文链接:https://culturesun.site/index.php/archives/691.htmlWhatWeb是一款kali自带的工具。可以识别网站。它认可网络技术,包括内容管理系统(CMS)、博客平台、统计/分析包、JavaScript库、网络服务器和嵌入式设备。WhatWeb有900多个插件,每个插件都可以识别不同的东西。它还......
  • Fibers and Threads in node.js – what for?
    https://bjouhier.wordpress.com/2012/03/11/fibers-and-threads-in-node-js-what-for/ Ilike node.js,andI’mnottheonlyone,obviously!Ilikeitprimarilyfortwothings:itissimple anditis veryfast.Ialreadysaiditmanytimesbutonemorewon’thu......
  • 网站指纹扫描插件(WhatRuns、Wappalyzer)
    我使用的是Chrome浏览器,需要到应用商店搜索下载WhatRunsWappalyzer......
  • [BZOJ4407]于神之怒加强版 CODE
    #include<bits/stdc++.h>#definelllonglong#defineFor(i,a,b)for(lli=(a);i<=(b);++i)#defineRep(i,a,b)for(lli=(a);i>=(b);--i)constllN=1e6+10;usingnamespacestd;constllmod=1e9+7;llvis[N],tot,p[N];voidinit(lln){//质数筛For......