第七届 山东省ACM Swiss-system tournament(归并思想)
来源:互联网 发布:厦门千象品牌策划 知乎 编辑:程序博客网 时间:2024/05/23 16:55
Swiss-system tournament
Problem Description
A Swiss-system tournament is a tournament which uses a non-elimination format. The first tournament of this type was a chess tournament in Zurich in 1895, hence the name "Swiss system". The tournament will be held based on following rules.
2*N contestants (indexed 1, 2, ..., 2*N) will have R rounds matches. Before the first round, every contestant has an origin score. After every match, winner will get 1 score and loser will get 0 score. Before and after every round, contestants will be sorted by their scores in descending order. Two contestants with the same score will be sorted by their index with ascending order.
In every round, contestants will have match based on the sorted list. The first place versus the second place, the third place versus the forth place, ..., the Kth place versus the (K + 1)th place, ..., the (2*N - 1)th place versus (2*N)th place.
Now given the origin score and the ability of every contestant, we want to know the index of the Qth place contestant. We ensured that there won’t be two contestants with the same ability and the contestant with higher ability will always win the match.
Input
For each test case, the first line contains three positive integers N (N <= 100,000), R (R <= 50), Q (Q <= 2*N), separated by space.
The second line contains 2*N non-negative integers, s1, s2, ..., s2*N, si (si<= 108) indicates the origin score of constant indexed i.
The third line contains 2*N positive integers, a1, a2, ..., a2*N, ai (ai<= 108) indicates the ability of constant indexed i.
Output
Example Input
12 4 27 6 6 710 5 20 15
Example Output
1
Hint
Versus
Scores after round
Index
/
①(10)
②(5)
③(20)
④(15)
Origin
/
7
6
6
7
Round 1
① VS ④ ②VS ③
7
6
7
8
Round 2
④ VS ① ③VS ②
7
6
8
9
Round 3
④ VS ③ ①VS ②
8
6
9
9
Round 4
③ VS ④ ①VS ②
9
6
10
9
Author
真心简单
#include <bits/stdc++.h>using namespace std;const int Max = 100100;struct node{ int sore; int ali; int index; bool operator < (const node &a)const { return sore == a.sore ? index<a.index : sore > a.sore; }}a[Max*2],b[Max],c[Max]; ///a为排序数组 b为赢的那一个void Solve(int n){ int num1 = 0,num2 = 0; for(int i = 0;i<n;i+=2) { if(a[i].ali > a[i+1].ali) { b[num1]= a[i]; b[num1].sore++; num1++; c[num2++] = a[i+1]; } else { b[num1]= a[i+1]; b[num1].sore++; num1++; c[num2++] = a[i]; } } int num = 0; int i = 0 ,j = 0; while(i<num1&&j<num2) { if(b[i].sore>c[j].sore || (b[i].sore == c[j].sore && b[i].index<c[j].index)) a[num++] = b[i++]; else a[num++] = c[j++]; } while(i<num1) a[num++] = b[i++]; while(j<num2) a[num++] = c[j++];}int main(){ int T; int n,m,k; scanf("%d",&T); while(T--) { scanf("%d %d %d",&n,&m,&k); n = 2*n; for(int i = 0;i<n;i++){ scanf("%d",&a[i].sore); a[i].index = i+1; } for(int i = 0;i<n;i++) scanf("%d",&a[i].ali); sort(a,a+n); while(m--) ///进行m轮比赛 Solve(n); printf("%d\n",a[k-1].index); } return 0;}
- 第七届 山东省ACM Swiss-system tournament(归并思想)
- 第七届ACM山东省赛-D Swiss-system tournament
- 第七届ACM山东省赛-D Swiss-system tournament
- 山东省第七届ACM省赛 Swiss-system tournament
- Hrbust 2311(Swiss-system tournament)归并排序
- 山东省acm省赛 D题Swiss-system tournetment
- SDUT 3563 Swiss-system tournament【思维+模拟】
- Execution of Paladin(山东省第七届acm j题)
- 第七届 山东省ACM Memory Leak(模拟 待整理)
- 第七届 山东省ACM Execution of Paladin(水题)
- 山东省第七届 ACM 省赛 Proxy (最短路)
- 山东省第七届ACM省赛题——Fibonacci(二分)
- 山东省第七届 ACM 省赛 Feed the monkey (dp)
- 【第七届山东省ACM竞赛】Square Number
- 2016第七届ACM山东省赛
- 第七届ACM山东省赛-A Julyed
- 第七届ACM山东省赛-B Fibonacci
- 第七届ACM山东省赛-C Proxy
- 机器人系统设计与控制技术作业和考核说明
- Apache性能优化之MPM选择和配置
- 【代码质量管理工具】--使用sonarLint提高代码质量
- Error MSB3073: The command regsvr32 /s /c出错
- 纹理采样和过滤
- 第七届 山东省ACM Swiss-system tournament(归并思想)
- LintCode-二叉树的所有路径
- opengl 绘图模式比较
- sqoop 知识及安装配置说明--hadoop安装系列之四
- Linux下"undefined reference to ‘pthread_create’"问题解决
- 使用fbo离屏渲染绘制图片
- 数字组合
- c++ 指针详解
- HDU