记录编号 |
76455 |
评测结果 |
AAAAATAAAA |
题目名称 |
[NOIP 2011]瑞士轮 |
最终得分 |
90 |
用户昵称 |
1azyReaper |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
2.055 s |
提交时间 |
2013-10-30 19:58:33 |
内存使用 |
4.89 MiB |
显示代码纯文本
#include <fstream>
//#include <cstdio>
using namespace std;
ifstream fin("swiss.in");
ofstream fout("swiss.out");
class student
{
public:
int score;
int position;
int value;
}a[200080],t,b[100008],c[100008],temp;
int qsort(student a[],int low1,int high1)
{
int low,high;
low=low1;
high=high1;
temp=a[low];
while(low<high)
{
while(low<high&&(a[high].score<temp.score||a[high].score==temp.score&&a[high].position>temp.position))
high--;
a[low]=a[high];
while(low<high&&(a[low].score>temp.score||a[low].score==temp.score&&a[low].position<temp.position))
low++;
a[high]=a[low];
}
a[low] = temp;
if(low1<low-1)
qsort(a,low1,low-1);
if(low+1<high1)
qsort(a,low+1,high1);
return 0;
}
int main()
{
int i,j,n,r,q,g,k;
fin>>n>>r>>q;
for(i=0;i<=2*n-1;i++)
{
fin>>a[i].score;
a[i].position = i+1;
}
for(i = 0;i<=2*n-1;i++)
fin>>a[i].value;
qsort(a,0,2*n-1);
for(i=1;i<=r;i++)
{
k=0;
g=0;
for(j=0;j<=2*n-2;j=j+2)
{
if(a[j].value<a[j+1].value)
{
a[j+1].score++;
b[k] = a[j+1];
c[g] = a[j];
k++;
g++;
continue;
}
if(a[j].value>a[j+1].value)
{
a[j].score++;
b[k] = a[j];
c[g] = a[j+1];
k++;
g++;
continue;
}
}
k=0;
g=0;
for(j = 0;j<=2*n-1;j++)
{
if(k>n-1&&g>n-1)
break;
if(k>n-1)
{
a[j] = c[g];
g++;
continue;
}
if(g>n-1)
{
a[j] = b[k];
k++;
continue;
}
if(b[k].score>c[g].score|| b[k].score==c[g].score && b[k].position<c[g].position)
{
a[j] = b[k];
k++;
}
else
{
a[j] = c[g];
g++;
}
}
}
fout<<a[q-1].position<<endl;
fin.close();
fout.close();
return 0;
}