UVALive 2318 水题
给出c 个竞争者.v 个投票人。每个投票人的投票顺序。问你谁会胜出。在第几轮。完全是个水题。比赛的时候debug接近两个点没过。因此差点放弃了整场比赛。猜测是错在找最大和第二大的序号哪里错的。因为我换了一种方法就AC了。
以后该尝试着删掉debug不过的代码。重写。最近比赛总是被虐成狗、不知道是不是被失望了、或者。
好好努力吧。只是希望自己每次都能有所进步就好了。总是行走在路上。其实很难。
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std; int t;
int rankk[][];
int vote[], vote2[];
int num[]; int main()
{
int t;
int c, v;
cin >> t;
while(t--)
{
cin >> c >> v;
for (int i=; i<v; ++i)
{
for (int j=; j<c; ++j)
cin >> rankk[i][j];
}
int max1 = , max2 = ;
memset(vote, , sizeof(vote));
for (int i=; i<v; ++i)
{
int temp = rankk[i][];
vote[temp]++;
}
for (int i=; i<=c; ++i)
{
vote2[i]= vote[i];
}
sort(vote2+, vote2+c+);
max1 = vote2[c];
max2 = vote2[c-];
int cnt = ;
int max2_id;
for (int i=; i<=c; ++i)
{
if (vote[i] == max1)
{
num[] = i;
break;
}
}
for (int i=; i<=c; ++i)
{
if (vote[i] == max2 && i!=num[])
{
num[] = i;
break;
}
} if (max1 > v/)
{
cout << num[] << ' ' << << endl;
continue;
}
else
{
int num1 = num[], num2 = num[];
memset(vote, , sizeof(vote));
for (int i=; i<v; ++i)
{
for (int j=; j<c; ++j)
{
int temp = rankk[i][j];
if (temp == num1 || temp == num2)
{
vote[temp]++;
break;
}
}
}
if (vote[num1] > vote[num2])
{
cout << num1 << ' ' << << endl;
continue;
}
else
{
cout << num2 << ' ' << << endl;
continue;
}
}
}
return ;
}
LOoK
UVALive 2318 水题的更多相关文章
- UVaLive 6591 && Gym 100299L Bus (水题)
题意:略. 析:不解释,水题. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include < ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,
1195: 相信我这是水题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 821 Solved: 219 Description GDUT中有个风云人 ...
- BZOJ 1303 CQOI2009 中位数图 水题
1303: [CQOI2009]中位数图 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2340 Solved: 1464[Submit][Statu ...
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
- ACM水题
ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...
随机推荐
- compile vi from source code
1.install ncurses library (vi depend on ncurses library) ./configure --prefix=/usr --with-termlib m ...
- SxsTrace
https://troubleshooter.xyz/wiki/fix-the-application-has-failed-to-start-because-the-side-by-side-con ...
- 51nod 1428 活动安排问题 (贪心+优先队列)
来源:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1428 首先按照开始时间从小到大排序. 其实只要维护一个结束时间的最 ...
- [SpringBoot] - 发送带附件的邮件
<!--发送email依赖--> <dependency> <groupId>org.springframework.boot</groupId> &l ...
- IDEA快捷键复习使用
https://www.jetbrains.com/help/idea/meet-intellij-idea.html 快捷键可以极快地进行代码编辑整理,在IDEA的快捷键中,除了有几个好像特别难按之 ...
- NS3 MyApp Class Reference
官方文档:MyApp 可以在下面的几个例子找到: examples/tutorial/fifth.cc examples/tutorial/seventh.cc examples/tutorial/s ...
- python删除所有自定义变量方法--转载
http://blog.sina.com.cn/s/blog_b2f983a50102yexs.html 当我们在pythonwin中创建多个变量后,通过dir()函数,可以看到所有已创建变量,这 ...
- 提高Intellij创建Maven工程的速度
按照默认的方式创建Maven工程的时候会发现Maven插件加载的很慢如下 解决方法:在创建的过程中,在Properties中添加一个参数archetypeCatalog=internal . 因为ar ...
- python 集合从头部删除元素
num_set = , , , , ]) num_set.pop() print(num_set) num_set.pop() print(num_set)
- html 获取鼠标左键事件,滚轮点击事件,右键点击事件
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...