HDU-4451-Dressing (2012年金华赛区J题)
Dressing
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2674 Accepted Submission(s): 1179
One day he wears his pants Nike, shoes Adiwang to go to school happily. When he opens the door, his mom asks him to come back and switch the dressing. Mom thinks that pants-shoes pair is disharmonious because Adiwang is much better than Nike. After being asked
to switch again and again Wangpeng figure out all the pairs mom thinks disharmonious. They can be only clothes-pants pairs or pants-shoes pairs.
Please calculate the number of different combinations of dressing under mom’s restriction.
For each case, the first line contains 3 integers N,M,K(1≤N,M,K≤1000) indicating the number of clothes, pants and shoes.
Second line contains only one integer P(0≤P≤2000000) indicating the number of pairs which mom thinks disharmonious.
Next P lines each line will be one of the two forms“clothes x pants y” or “pants y shoes z”.
The first form indicates pair of x-th clothes and y-th pants is disharmonious(1≤x≤N,1 ≤y≤M), and second form indicates pair of y-th pants and z-th shoes is disharmonious(1≤y≤M,1≤z≤K).
Input ends with “0 0 0”.
It is guaranteed that all the pairs are different.
2 2 2
0
2 2 2
1
clothes 1 pants 1
2 2 2
2
clothes 1 pants 1
pants 1 shoes 1
0 0 0
8
6
5
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
using namespace std; int a[1010][1010], b[1010][1010], c[1010]; int main()
{
int N, M, K, P;
char str1[10], str2[10];
int t1, t2;
while(scanf("%d %d %d", &N, &M, &K)==3, N || M || K)
{
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
scanf("%d", &P);
while(P--)
{
scanf("%s %d %s %d", &str1, &t1, &str2, &t2);
if(strcmp(str1,"clothes")==0)
{
a[t1][t2]=1;
}
else
{
b[t1][t2]=1;
c[t1]++;
}
}
int ans=0;
for(int i=1;i<=N;i++)
for(int j=1;j<=M;j++)
if(a[i][j]==0)
ans+=(K-c[j]);
printf("%d\n",ans);
}
return 0;
}
HDU-4451-Dressing (2012年金华赛区J题)的更多相关文章
- hdu 4451 37届金华赛区 J题
题意:给出衣服裤子鞋子的数目,有一些衣服和裤子,裤子和鞋子不能搭配,求最终的搭配方案总数 wa点很多,我写wa了很多次,代码能力需要进一步提升 #include<cstdio> #incl ...
- HDU 4451 Dressing
HDU 4451 Dressing 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=4451 Description Wangpeng has ...
- [hdu5136]Yue Fei's Battle 2014 亚洲区域赛广州赛区J题(dp)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud 现场赛的时候由于有个地方有点小问题,没有成功AC,导致与金牌失之交臂. 由于今天下 ...
- hdu 4442 Physical Examination (2012年金华赛区现场赛A题)
昨天模拟赛的时候坑了好久,刚开始感觉是dp,仔细一看数据范围太大. 题目大意:一个人要参加考试,一共有n个科目,每个科目都有一个相应的队列,完成这门科目的总时间为a+b*(前面已完成科目所花的总时间) ...
- hdu 4451 Dressing 衣服裤子鞋 简单容斥
Dressing Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- 【HDU 4451 Dressing】水题,组合数
有衣服.裤子.鞋数量分别为n,m,k,给出p对不和谐的衣-裤或裤-鞋搭配,问一共有多少种和谐的衣裤鞋的搭配. 全部的组合有Cn1Cm1Ck1种. 设p对中有p1对衣-裤,p2对裤-鞋,则不和谐的搭配共 ...
- hdu 4445 37届金华赛区 D题
题意:给一个坦克的高度,求炮弹能打中最多的数量 枚举角度,作为一名学霸虽然很快推出了公式,但是却没有考虑到,角度可以朝下的情况 #include<cstdio> #include<i ...
- hdu 4452 37届金华赛区 K题
题意:给一个n*n的格子,1在左上角,2在右下角,每个人有一个初始速度和方向,若遇到边缘,则朝相反方向前进,若两个人相遇则交换方向(注意方向改变后,人仍然需要移动),同时,每个人每过t1,t2时间就会 ...
- hdu 4442 37届金华赛区 A题
题意:给出一些队伍,每个队伍有初始等待时间和每秒增加的时间,求最短时间 假设有两个队初始时间和每秒增加时间为a1,b1和a2,b2 若第选择第一个的时间小于第二个,则 a1+a2+a1*b2<a ...
随机推荐
- vs code golang代码自动补全
“go.useCodeSnippetsOnFunctionSuggest”: true 文件-->首选项--->设置--->用户设置 添加下行:然后就可以自动补全了,包括() “go ...
- indeed 4.22 第一次网测
1.第一题 没有看 2. 由于数据范围很小,所以每一层需要全排列,寻找最小的花费,然后所有层加起来就是最后的结果. #include<bits/stdc++.h> #define pb p ...
- JS 有趣的eval优化输入验证
//eval就是计算字符串[可以放任何js代码]里的值 . var str1='12+3'; eval(str1); . var str2='[1,2,3]'; eval(str2[]); .eval ...
- P1569 [USACO11FEB]属牛的抗议Generic Cow Prote…
题目描述 Farmer John's N (1 <= N <= 100,000) cows are lined up in a row and numbered 1..N. The cow ...
- 使用cnblogs发布第一篇文章,HelloWorld
HelloWorld! 瞅瞅源码的样式,嗯,语法高亮还是可以的,辨识度还是挺高的. <!DOCTYPE html> <html> <head> <meta c ...
- Android点击跳转到淘宝的某一商品详情页或者某一店铺页面
最近项目的有个需求是点击购买资料按钮进入淘宝界面,简单分析一下,如果用户手机有淘宝就打开淘宝的页面,没有的话也可以选择使用webView进行展示,还是使用手机浏览器进行展示. 判断有无淘宝的代码就不贴 ...
- 除了Google,你还应该试试的8个搜索引擎
在信息高速公路上,我们通过浏览器在web的世界里尽情驰骋.想要成为一个好的驾驶员,掌握方向的能力很重要.这很像是Google在我们生活中扮演的角色,通过它可以找到一个又一个的信息宝藏.Google ...
- VHDL之User-defined data types
VHDL allows the user to define own data types. 1 user-defined integer types -- This is indeed the pr ...
- 调试程序时找不到DLL的解决办法
最近调试程序的经常弹出找不到DLL.只好一个个把DLL拷贝到程序目录下(我是拷贝到源文件目录,也有人说是Debug目录). 其实可以这么设置: 项目属性->配置属性->调试->工作目 ...
- 红黑联盟 php相关资讯
http://www.2cto.com/tag/phpbanben.html