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 ...
随机推荐
- Swift备忘录
Swift 备忘录 2015-4 一.简介 1.Swift 语言由苹果公司在2010年7月开始设计,在 2014 年6月推出,在 2015 年 12 月 3 日开源 2.特点(官方): (1)苹果宣称 ...
- go之数据类型转换和类型断言
一.类型转换 1.1 简单类型转换 格式 valueOfTypeB = typeB(valueOfTypeA) int 转 float64 package main import "fmt& ...
- Hive搭建与简单使用
hive搭建与简单使用(1) 标签(空格分隔): hive,mysql hive相当于编译器的组件,他并不存储数据,元数据存储在mysql中,数据则存放在hdfs中,通过hive,可以利用sql语句对 ...
- TCP/IP详解(三)
超时与重传: TCP在发送一个包时,启动一个定时器,如果在定时器溢出之前没有收到ACK,则认为发出的包丢失了,此时会重传丢失的包.这就是超时重传. 其中定时器的时间不是一个固定值,它是根据RTT计算的 ...
- POJ 1010 题目翻译+题解
题目实在是太难懂了,我翻译了一下... STAMPS Description Have you done any Philately lately? 你最近有没有集邮? You have been h ...
- F - Modular Exponentiation
Problem description The following problem is well-known: given integers n and m, calculate 2n mod m, ...
- Block的本质与使用
1.block的基本概念及使用 blcok是一种特殊的数据结构,它可以保存一段代码,等到需要的时候进行调用执行这段代码,常用于GCD.动画.排序及各类回调. Block变量的声明格式为: 返回值类型( ...
- 【Oracle】to_char技巧
Select to_char(sysdate,'ss') from dual; 取当前时间秒部分 Select to_char(sysdate,'mi') from dual; 取 ...
- oracle从入门到精通复习笔记
为方便大家跟着我的笔记练习,为此提供数据库表文件给大家下载:点我下载 描述一个表用 desc employees过滤重复的部门 select distinct department_id from e ...
- cannot find Toolkit in /usr/local/cuda-8.0
对于新版本ubuntukylin17.04安装CUDA时出现 cannot find Toolkit in /usr/local/cuda-8.0 问题 尝试了各种方法,均不妥当...... 参考:h ...