题目链接

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3961

题意

给出两个人的发消息的记录,然后 如果有两人在连续M天及以上 互发消息,超过几天 加几点 友谊值 最后求 友谊值

思路

先把第一个 连续区间 >= M 的 存下来 然后第二次 输入的时候 去判断。

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream> using namespace std;
typedef long long LL; const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6; const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7; int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n, q;
int i, j;
scanf("%d%d", &n, &q);
map <string, string> M;
M.clear();
string s, temp = "";
for (i = 0; i < q; i++)
temp += "0";
int m;
scanf("%d", &m);
for (i = 0; i < m; i++)
{
cin >> s;
M[s] = temp;
}
for (i = 0; i < q; i++)
{
scanf("%d", &m);
for (j = 0; j < m; j++)
{
cin >> s;
M[s][i] = '1';
}
}
// map <string, string>::iterator it;
// for (it = M.begin(); it != M.end(); it++)
// cout << it -> first << " " << it -> second << endl;
string ans;
int num;
for (i = 0; i < n; i++)
{
temp.clear();
for (j = 0; j < q; j++)
{
scanf(" %d", &num);
temp += num + '0';
}
int flag = 0;
ans.clear();
map <string, string>:: iterator it;
for (it = M.begin(); it != M.end(); it++)
{
if (it -> second == temp )
{
if (flag == 1)
{
flag = 0;
break;
}
else
{
flag = 1;
ans = it -> first;
}
}
}
if (flag)
cout << ans << endl;
else
printf("Let's go to the library!!\n");
}
}
}

ZOJ 3961 Let's Chat 【水】的更多相关文章

  1. ZOJ - 3961 Let's Chat(区间相交)

    题意:给定一个长度为n的序列,A和B两人分别给定一些按递增顺序排列的区间,区间个数分别为x和y,问被A和B同时给定的区间中长度为m的子区间个数. 分析: 1.1 ≤ n ≤ 109,而1 ≤x, y  ...

  2. 2017浙江省赛 D - Let's Chat ZOJ - 3961

    地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3961 题目: ACM (ACMers' Chatting Messe ...

  3. Let's Chat ZOJ - 3961

    ACM (ACMers' Chatting Messenger) is a famous instant messaging software developed by Marjar Technolo ...

  4. ZOJ 3778 C - Talented Chef 水题

    LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3778 题意:有n道菜,每道菜需要\(a_i\)道工序,有m个锅可 ...

  5. ZOJ 3782 G - Ternary Calculation 水

    LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782 题意:给出3个数和两个符号(+-*/%) 思路:拿到题目还 ...

  6. ZOJ 3959 Problem Preparation 【水】

    题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3959 AC代码 #include <cstdio> ...

  7. ZOJ 3958 Cooking Competition 【水】

    题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3958 AC代码 #include <cstdio> ...

  8. zoj 3827 Information Entropy 【水题】

    Information Entropy Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Information ...

  9. ZOJ 1796 Euchre Results 数学水题

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1796 题意: 四个人玩游戏,已知三个人的输赢情况,求第四个人的输赢情况. ...

随机推荐

  1. OpenAPI初体验

    问题的一开始源于客户和服务部门抱怨我的REST API文档写得不好,然后又了解到 django rest framework 利用 coreapi 能自动生成文档,再就是看到 swagger.io 上 ...

  2. Python 2.7 中使用 Print 方法

    print ("test",file=name)类似的方法在python 2中需要先引入 __future__才可使用 import __futhure__ import prin ...

  3. PHP基础之Autoload

    PHP的自动加载autoload机制很重要,这里做2个小练习 原创文章,转载请注明:http://www.cnblogs.com/phpgcs 文件结构如下,2种方式实现自动加载 1,自定义函数 2, ...

  4. D - Sigma Function 1~n内有多少个约数和为偶数

    /** 题目:D - Sigma Function 链接:https://vjudge.net/contest/154246#problem/D 题意:求1~n内约数和为偶数的数的个数. 思路:一个数 ...

  5. Linux 总结2

    cd                                             pwd                                            mkdir ...

  6. ssh远程登录+查看系统版本+使用scp命令上传下载

    ssh远程登录命令简单实例   ssh命令用于远程登录上Linux主机.   常用格式:ssh [-l login_name] [-p port] [user@]hostname 更详细的可以用ssh ...

  7. weex - 创建项目

    初始化 请确保你已经安装了 Node.js,然后全局安装 weex-toolkit. npm install weex-toolkit -g 这条命令会向你命令行环境中注册一个 weex 命令.你可以 ...

  8. Laravel5.1 模型--ModelFactory

    今天要说的是模型工厂,它是可以快速生成一些测试数据的东西,之前我们介绍过Seeder,当我们使用模型访问数据时 可以用模型工厂搭配Seeder使用. 1 编写一个ModelFactory ModelF ...

  9. POJ1365 Prime Land【质因数分解】【素数】【水题】

    题目链接: http://poj.org/problem?id=1365 题目大意: 告诉你一个数的质因数x的全部底数pi和幂ei.输出x-1的质因数的全部底数和幂 解题思路: 这道题不难.可是题意特 ...

  10. hdu5646(数学)

    小学数学,脑补 一开始看到这题,猜了个规律想写但是我是拒绝的. 因为我无法证明. 好吧,主要还是小学数学没学好吧. 要理解这题,首先得搞懂一个重要问题.假设C=A+B,怎样选择两个正整数使得A*B最大 ...