ZOJ 3961 Let's Chat 【水】
题目链接
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 【水】的更多相关文章
- ZOJ - 3961 Let's Chat(区间相交)
题意:给定一个长度为n的序列,A和B两人分别给定一些按递增顺序排列的区间,区间个数分别为x和y,问被A和B同时给定的区间中长度为m的子区间个数. 分析: 1.1 ≤ n ≤ 109,而1 ≤x, y ...
- 2017浙江省赛 D - Let's Chat ZOJ - 3961
地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3961 题目: ACM (ACMers' Chatting Messe ...
- Let's Chat ZOJ - 3961
ACM (ACMers' Chatting Messenger) is a famous instant messaging software developed by Marjar Technolo ...
- ZOJ 3778 C - Talented Chef 水题
LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3778 题意:有n道菜,每道菜需要\(a_i\)道工序,有m个锅可 ...
- ZOJ 3782 G - Ternary Calculation 水
LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782 题意:给出3个数和两个符号(+-*/%) 思路:拿到题目还 ...
- ZOJ 3959 Problem Preparation 【水】
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3959 AC代码 #include <cstdio> ...
- ZOJ 3958 Cooking Competition 【水】
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3958 AC代码 #include <cstdio> ...
- zoj 3827 Information Entropy 【水题】
Information Entropy Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Information ...
- ZOJ 1796 Euchre Results 数学水题
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1796 题意: 四个人玩游戏,已知三个人的输赢情况,求第四个人的输赢情况. ...
随机推荐
- angularjs 可以加入html标签方法------ng-bind-html的用法总结(2)
angular-ngSanitize模块-$sanitize服务详解 本篇主要讲解angular中的$sanitize这个服务.此服务依赖于ngSanitize模块. 要学习这个服务,先要了解另一个指 ...
- jquery中Uncaught TypeError: $(...).ajaxUpload is not a function(…)错误解决方法
错误原因:该函数不是jquery的核心函数,所以需要外部引入ajaxfileupload.js文件,可能是没有引入,或者引入的js文件互相冲突 解决方法:每次进入一个函数之前打印该函数所有的js文件, ...
- objc_setAssociatedObject 使用(转)
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ...
- iOS多线程(转)
关于iOS多线程,你看我就够了 字数8596 阅读28558 评论74 喜欢313 在这篇文章中,我将为你整理一下 iOS 开发中几种多线程方案,以及其使用方法和注意事项.当然也会给出几种多线程的案例 ...
- Java并发编程(九)安全发布
之前讨论是如何将对象封闭在线程之中,这样可以减少一些并发带来的同步和可见性问题.但是在有些时候,我们希望在多个线程间共享对象,此时必须确保安全地进行共享. [不安全发布的示例] 可见性问题:其他线程看 ...
- configure: error: Cannot find OpenSSL's libraries
在Ubuntu 12.4.1 X64 位下编译安装PHP时提示 configure: error: Cannot find OpenSSL's libraries 确认已安装过 openssl.lib ...
- Ordering Tasks UVA - 10305 图的拓扑排序
John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task i ...
- All in All - poj 1936 (子串)
字符串子序列查找问题,设置两个指针,一个指向子序列,另一个指向待查找的序列,查找个字符串一次即可判断. #include <iostream> #include <string. ...
- 深入理解:单一入口、MVC、ORM、CURD、ActiveRecord概念
本篇文章是对单一入口.MVC.ORM.CURD.ActiveRecord概念进行了详细的分析介绍,需要的朋友参考下 MVC MVC是一个设计模式,它强制性的使应用程序的输入.处理和输出分开.使 ...
- python 使用正则表达式的爬虫
下面我们一起尝试一下爬取内涵段子网站: http://www.neihan8.com/article/list_5_1.html 打开之后,不难看到里面一个一个灰常有内涵的段子,当你进行翻页的时候,注 ...