UVA - 11222 Only I did it!
来源:互联网 发布:vue.js 显示隐藏 编辑:程序博客网 时间:2024/05/20 06:06
题目大意:T 个样例,每个 3 行,分别代表第 1 2 3 个人做的题数,每行第一个数字表示他做了几题,后面是题目编号。我们要找到每个样例中单独完成的题目最多的人,也就是在自己完成的题目当中,另外两个都没有解出来的题目最多的人。输出他的编号,单独完成的题目数量,单独完成的题目编号(升序)。
解题思路:思路比较简单就是去查找当前题目另外两个人有没有做过就行,没有的话题号存起来然后数量 ++,处理起来有点复杂。
然后怀疑此题 udebug 有问题,代码过了 udebug 里面 2000+ 的样例却依旧 WA……
迷之WA 先占坑
#include<iostream> #include<cstdio>#include<cmath>#include<string.h>#include<stdlib.h>#include<algorithm>using namespace std;int p[3][1010];int tmp[3][1010];int ans[3][1010];int num[3];int s[3];int MAX;int main() { int T, S; scanf("%d", &T); for (int C = 1; C <= T; C++) { memset(p, 0, sizeof(p)); memset(ans, 0, sizeof(ans)); memset(num, 0, sizeof(num)); for (int i = 0; i < 3; i++) { scanf("%d", &s[i]); for (int j = 0; j < s[i]; j++) scanf("%d", &tmp[i][j]); } for (int i = 0; i < 3; i++) { sort(tmp[i], tmp[i]+s[i]); int tag = 1; p[i][0] = tmp[i][0]; for (int j = 1; j < s[i]; j++) if (tmp[i][j-1] != tmp[i][j]) p[i][tag++] = tmp[i][j]; s[i] = tag; } int t1, t2; int i, j, k, m, n; MAX = 0; for (i = 0; i < 3; i++) { int tag = 0; m = (i+1) % 3; n = (i+2) % 3; for (j = 0; j < s[i]; j++) { t1 = t2 = 0; for (k = 0; k < s[m]; k++) if (p[i][j] == p[m][k]) { t1 = 1; break;} for (k = 0; k < s[n]; k++) if (p[i][j] == p[n][k]) { t2 = 1; break;} if (t1 || t2) continue; ans[i][tag++] = p[i][j]; } num[i] = tag; if (tag > MAX) MAX = tag; } printf("Case #%d:\n", C); for (int i = 0; i < 3; i++) if (num[i] == MAX) { printf("%d %d", i+1, MAX); if (MAX) for (int j = 0; j < MAX; j++) printf(" %d", ans[i][j]); printf("\n"); } }return 0; }
0 0
- UVa 11222 - Only I did it!
- UVA - 11222 Only I did it!
- How I Did It: John Vechey, Founder of PopCap
- We Did It!
- I did nothing recently.
- Today I did morning
- from makefile which i did not make it as a file
- Just I did something wrong!
- API mixerGetNumDevs I did notd1
- API IsValidCodePage I did expd1
- where i did not know?
- I’m Sure It Will Only Take You A Few Days To Code
- I’m Sure It Will Only Take You A Few Days To Code
- If I have been able to see further, it was only because I stood on the shoulders of giants.
- It's only me
- I did an SDK update last night and it moved adb.exe. In its place it left a file called "adb_has_mov
- I only have today
- Lessons from Leaders: How JBoss did it
- LeetCode 231: Power of Two
- 数据面控制面
- 我的第一篇博客
- 关于OpenCV的配置问题
- C/C++中的const
- UVA - 11222 Only I did it!
- Centos 7 64 位 磁盘的挂载
- 385. Mini Parser
- 《数据结构与算法》学习笔记17 递归_三角数字+阶乘
- java学习之路 之 Java集合练习题
- MQTT协议简记
- 如何一进入到搜索界面就自动获取到edittext的焦点并自动弹出软键盘
- 关于mysql的数据库放在哪个文件下
- python3 windows 10 Beautiful Soup4 安装指南