比赛 |
防止颓废的小练习v0.15 |
评测结果 |
AAAAAAAAAA |
题目名称 |
瑞士轮 |
最终得分 |
100 |
用户昵称 |
Kulliu |
运行时间 |
0.966 s |
代码语言 |
C++ |
内存使用 |
4.89 MiB |
提交时间 |
2016-10-17 19:43:53 |
显示代码纯文本
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<cctype>
#include<ctime>
#include<cmath>
#include<queue>
#include<list>
#include<map>
#include<set>
using namespace std;
#define INF 0x7fffffff
int n,r,q,i,j,ji;
struct node{
int s,p,ii;
}a[200010],w[100010],l[100010];
int cmp(node a,node b){
if (a.s==b.s) return a.ii<b.ii;
return a.s>b.s;
}
int main(){
freopen("swiss.in","r",stdin);
freopen("swiss.out","w",stdout);
scanf("%d%d%d",&n,&r,&q);
n*=2;
for ( i=1;i<=n;++i) scanf("%d",&a[i].s),a[i].ii=i;
for ( j=1;j<=n;++j) scanf("%d",&a[j].p);
sort(a+1,a+1+n,cmp);
for ( ji=1;ji<=r;ji++)
{
int wi=1,lo=1;
for ( i=1;i<=n;i+=2)
{
if (a[i].p<a[i+1].p) w[wi++]=a[i+1],l[lo++]=a[i];
else if (a[i].p>a[i+1].p)l[lo++]=a[i+1],w[wi++]=a[i];
}
wi--;lo--;
for ( i=1;i<=n/2;i++) w[i].s++;
int x=1,y=1;
i=0;
while( x<=n/2 && y<=n/2)
{
if (w[x].s>l[y].s) a[++i]=w[x++];
if (w[x].s<l[y].s) a[++i]=l[y++];
if (w[x].s==l[y].s&&w[x].ii>l[y].ii) a[++i]=l[y++];
if (w[x].s==l[y].s&&w[x].ii<l[y].ii) a[++i]=w[x++];
}
if (x>n/2)
while (y<=n/2) a[++i]=l[y++];
else while (x<=n/2) a[++i]=w[x++];
}
printf("%d",a[q].ii);
return 0;
}