hdu-4451 思维题
来源:互联网 发布:软件项目管理总结报告 编辑:程序博客网 时间:2024/05/30 02:24
这个题一开始想的就是只有有一套衣服就加2然后有重复的就需要减一,就用这个方法,写了三遍,wa了三遍,最后发现那个数组没有遍历最后一个元素
所以那个题一直错,后来队友用了另外的方法搞定了,自己比赛结束前也没有看出来这个错误,下面贴上两个代码,
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <vector>#include <string>#include <map>#include <math.h>#include <stack>#define LL long longusing namespace std;const int INF = 0x3f3f3f3f;int dir[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};const int maxn = 1000 + 10;int m,n,k;int a[maxn];int b[maxn];int N;int a1,b1;string c1,c2;int main(){ while(scanf("%d%d%d",&n,&m,&k)&&(n||m||k)) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); int sum = 0; scanf("%d",&N); for(int i = 0; i < N; i++) { cin>>c1>>a1>>c2>>b1; if(c1 == "clothes") { a[b1]++; } else { b[a1]++; } } //cout<<a[1]<<b[1]<<endl; for(int i = 1; i <= m; i++) { sum+=((n - a[i]) * (k - b[i])); } printf("%d\n",sum); } return 0;}
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <vector>#include <string>#include <map>#include <math.h>#include <stack>#define LL long longusing namespace std;const int INF = 0x3f3f3f3f;int dir[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};const int maxn = 1000 + 10;int m,n,k;vector<int> a[maxn];int b[maxn];int a1,b1;int N;string c1,c2;int main(){ while(scanf("%d%d%d",&n,&m,&k)&&(n||m||k)) { for(int i=1;i<=n;i++) a[i].clear(); memset(b,0,sizeof(b)); int ans = 0,num=0,sum=0; scanf("%d",&N); if(N==0) { printf("%d\n",m*n*k); continue; } for(int i = 0; i < N; i++) { cin>>c1>>a1>>c2>>b1; if(c1 == "clothes") { a[a1].push_back(b1); } else { b[a1]++; } } for(int i=1;i<=n;i++) if(a[i].size()) { for(int j=0;j<a[i].size();j++) { int zz=a[i][j]; ans=ans+b[zz]; num++; } } sum+=num*k; num=0; for(int i=1;i<=m;i++) if(b[i]) { num+=b[i]; } sum+=num*n; int hh=n*m*k-sum+ans; printf("%d\n",hh); } return 0;}
阅读全文
0 0
- hdu-4451 思维题
- hdu 5101 思维题
- hdu 5744 思维题
- hdu 5873 思维题
- HDU 5963 思维题
- HDU 5969 思维题
- HDU 6095 思维题
- HDU 5596 思维题(逆向思维)*
- hdu 5014 思维题/推理
- hdu 4803 贪心/思维题
- hdu 4474 BFS+思维题
- hdu 5223 GCD 思维题
- HDU 5301 Buildings(思维题)
- Hdu-5301 Buildings(思维题)
- hdu 5805 简单思维题
- hdu 4811 Ball 思维题
- hdu 4473 Exam (思维题 问题转化)
- hdu 4550 贪心 思维题 不错
- 二:redis3.x-cluster集群于spring整合
- 学习Git需要清楚的几个术语以及常用的Git命令总结
- 【079】利用“剪叶子”算法实现树形结构的搜索功能,用Vue.js实现
- react dva 碎片01
- oracle中rownum详解
- hdu-4451 思维题
- Linux下安装mysql
- Go语言的安装与设置
- Codeforces Round #394 (Div. 2) E. Dasha and Puzzle —— 构造 + 贪心
- Android 如何判断当前线程是否是主线程
- React 中被忽略的函数组件(Functional Components)
- js事件浏览器兼容案例
- iOS 内存恶鬼drawRect
- K线绘制接口设计