首页 技术 正文
技术 2022年11月17日
0 收藏 824 点赞 2,723 浏览 2133 个字

17984 FFF团的怒火

该题有题解

时间限制:1000MS  内存限制:65535K
提交次数:55 通过次数:3 收入:3

题型: 编程题   语言: G++;GCC;VC;JAVA

Description

在信软学院,男女比例失衡已经是习以为常的事情。
在这样的一个学院,诞生了一个神秘的组织,FFF团。
O O O
/F\/F\/F\
/ \/ \/ \
他们的任务是将一切不是真爱的爱情扼杀在摇篮中。
对于某些信软学院的学生,每天都只有一些时间是空闲的,其他时间都只能默默地打代码。
在这段空闲的时间里,所有男生都会去寻找一位空闲的女生,希望能与其进行一次美妙的约会。
然而FFF团的团长——小邪早已看穿一切。
为了防止FFF团团员做出过激行为,小邪决定对所有有着同一段空闲时间的异性进行监控。
现在,小邪想知道,这样的异性有多少对。但是如果小邪现在不对团员进行监控,将会发生严重的后果,于是,统计的任务就交了给你。出题人:K·小邪

输入格式

第一行是两个整数n,m(0 <= n,m <= 100),分别代表男生的数量和女生的数量接下来输入n个男生的数据,对于每个男生有一组数据
每组数据的第一行为一个整数t( 0 <= t <= 10 ),代表该男生拥有的空闲时间段数量
接下来为t行
每行的格式为XX:XX-XX:XX (00:00 <= XX:XX <= 23:59)
代表其在XX:XX至XX:XX的时间段有空闲时间,但是可能跨越一天接下来m个女生的数据,输入格式同男生

输出格式

输出一个整数,代表有可能见面的男女的对数

输入样例

(Sample #XX:不是输入的一部分)
Sample #1:1 1
1
23:59-00:01
1
08:00-19:00Sample #2:1 2
2
19:30-19:33
00:00-08:00
1
07:30-09:00
1
19:30-19:33

输出样例

Sample #1:
0Sample #2:
2

提示

注意端点相交也算是有可能见面的
比如08:00-09:00是可能与09:00-10:00见面的
并且对于同一个人输入的区间可能有重叠这题都说不清楚的,不知道跨了一天算明天的还是算谁。然后是算同一天的,也就是
23:59-07:00 和 01:00-02:00是相交的。。。晕。。
然后这题又不能用scanf("%d",) != EOF,这样会错误。。坑啊
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int maxn = + ;
struct node {
int num;
bool book[maxn];
}boy[ + ], girl[ + ];
int n, m;
void work() {
scanf("%d%d", &n, &m);
for (int i = ; i <= n; ++i) {
int t;
scanf("%d", &t);
boy[i].num = t;
while (t--) {
int a, b, c, d;
scanf("%d:%d-%d:%d", &a, &b, &c, &d);
int begin = a * + b;
int end = c * + d;
if (begin > end) {
for (int j = begin; j <= ; ++j) {
boy[i].book[j] = true;
}
for (int j = ; j <= end; ++j) {
boy[i].book[j] = true;
}
} else {
for (int j = begin; j <= end; ++j) {
boy[i].book[j] = true;
}
}
}
}
for (int i = ; i <= m; ++i) {
int t;
scanf("%d", &t);
girl[i].num = t;
while (t--) {
int a, b, c, d;
scanf("%d:%d-%d:%d", &a, &b, &c, &d);
int begin = a * + b;
int end = c * + d;
if (begin > end) {
for (int j = begin; j <= ; ++j) {
girl[i].book[j] = true;
}
for (int j = ; j <= end; ++j) {
girl[i].book[j] = true;
}
} else {
for (int j = begin; j <= end; ++j) {
girl[i].book[j] = true;
}
}
}
}
int ans = ;
for (int i = ; i <= n; ++i) {
for (int j = ; j <= m; ++j) {
for (int k = ; k <= maxn - ; ++k) {
if (boy[i].book[k] && girl[j].book[k]) {
ans++;
break;
}
}
}
}
printf("%d\n", ans);
}int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
work();
return ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,028
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,518
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,365
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,146
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,780
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,857