/*第4场多校联合训练解题报告——详见杭电ACM微博~
DressingTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1574    Accepted Submission(s): 670Problem Description
Wangpeng has N clothes, M pants and K shoes so theoretically he can have N×M×K different combinations of dressing.
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.Input
There are multiple test cases.
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.Output
For each case, output the answer in one line.Sample Input
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 0Sample Output
8
6
5Source
2012 Asia JinHua Regional Contest题意:略。思路:
简单的组合问题,注意加上重复的就是(在一个点上左边的线乘以右边的线的个数)
*/
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
using namespace std;
#define maxn 1100
int cpn[maxn],psk[maxn];
int main()
{int sum,i,p,a,b,n,m,k,tmp;char s[15];while(scanf("%d%d%d",&n,&m,&k),n||m||k){memset(cpn,0,sizeof(cpn));memset(psk,0,sizeof(psk));scanf("%d",&p);sum=n*m*k;tmp=0;for(i=0;i<p;i++){scanf("%s%d%s%d",s,&a,s,&b);if(strcmp(s,"pants")==0){cpn[b-1]++;tmp+=k;}else{psk[a-1]++;tmp+=n;}}for(i=0;i<m;i++){tmp-=cpn[i]*psk[i];}printf("%d\n",sum-tmp);}return 0;
}

转载于:https://www.cnblogs.com/heqinghui/p/3234622.html

hdu-4451-Dressing相关推荐

  1. HDU——1106排序(istringstream的使用、STLvector练习)

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submiss ...

  2. hdu 5438 Ponds 拓扑排序

    Ponds Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/contests/contest_showproblem ...

  3. HDU 1248 寒冰王座(全然背包:入门题)

    HDU 1248 寒冰王座(全然背包:入门题) http://acm.hdu.edu.cn/showproblem.php?pid=1248 题意: 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票 ...

  4. hdu 1312 Red and Black 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1312 第二条深搜,题目并不难,但是做了我好久好久,由于一个细节,让我赌上了一个晚上的时间. 题目大意: ...

  5. HDU 1429 胜利大逃亡(续) (BFS+位压缩)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1429 胜利大逃亡(续) Time Limit: 4000/2000 MS (Java/Others)  ...

  6. hdu 1272 小希的迷宫

    Problem Description 上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走.但是她设计迷宫的思路不一样,首先她认为所有的通道都应该 ...

  7. HDOJ 1157 HDU 1157 Who's in the Middle ACM 1157 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋   题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=1157 题目描述: ...

  8. 大数加法【HDU 1002】

    大数加法模板 一般的加法只要int类型的两数直接相加即可,大一点的数可以设为long long类型,而超过长整型的数则属于大数问题了,大数加法其实也比较简单,利用数组实现就可以啦: 主要思想如下: ( ...

  9. hdu 2665(主席树查询区间k大值)

    先贴我自己写的代码做模板虽然跟原博主没什么两样.(一开始空间开的4*maxn,交到hdu上一直TLE很奇怪) #include<bits/stdc++.h> using namespace ...

  10. hdu 1599 find the mincost route(找无向图最小环)(floyd求最小环)

    ps(我到今天才知道Floyd的核心思想是动态规划==) hdu 1599 find the mincost route(找无向图最小环) 注意!这里写成   #define data 0x3f3f3 ...

最新文章

  1. MOSS的CSS样式说明,一个老外总结的
  2. 关于SQLServer2005的学习笔记——约束、Check、触发器的执行顺序
  3. 宇瞻U盘出现无法格式化 写保护的完美解决办法 厂家提供的
  4. shiro框架_Shiro安全框架(下)
  5. web前端技巧-ES6新特性与重点知识汇总(一)
  6. Cause: java.sql.SQLException: Invalid parameter object type. Expected 'com.jd.sns.biz.api.domain.Plu
  7. Tomcat 总体结构
  8. python-PyQuery详解
  9. java语言中application异常退出和线程异常崩溃的捕获方法,并且在捕获的钩子方法中进行异常处理
  10. 大数据分析的四大趋势有哪些
  11. 专业的格式转换工具pdf2cad发布v11,支持当前所有的Windows和Mac操作系统
  12. MAC wps中选中的页面和缩放打印
  13. 硕士研究生的文献阅读方法以及文献阅读笔记模板
  14. 如何在WPS中加入图表清单(类似生成自动目录)
  15. 故障树手册(Fault Tree handbook)(3)
  16. u盘iso安装服务器系统怎么安装win7系统安装,u盘装系统怎么直接安装win7系统iso文件...
  17. 新手程序员必备10大技能
  18. 直播预告 | 端云协同的淘宝机器学习系统
  19. 华为鸿蒙系统专利申请,华为“鸿蒙”系统进一步推进,UI界面获得专利,谷歌慌了!...
  20. miumiu音乐app总结

热门文章

  1. python续行_python中如何优雅续行和换行
  2. call线程起名字_Java线程的5个使用技巧
  3. 周期三角波傅里叶级数例题_傅里叶详解之傅里叶级数
  4. 开源项目工时系统_SpringBoot 微信点餐开源系统!综合运用项目,值得一看!
  5. linux6 epel yum源,CentOS6下yum源与epel源配置
  6. 支持php,让Apache支持PHP语言
  7. python读取usb扫码枪数据_USB
  8. springboot项目实战_2019学习进阶之路:高并发+性能优化+Spring boot等大型项目实战...
  9. gerber文件怎么导贴片坐标_PCBA贴片加工厂家的上机贴片编程
  10. 如何估算代码量_没有量杯,没有称,如何估算碳水化合物?