洛谷P1309 瑞士轮【排序】

题目描述 https://www.luogu.org/problemnew/show/P1309
简单的sort会超时,需要两个数组分别记录获胜者和失败者,这样分数依然单调,最后再合在一起。

#include
#include
#include
#include
using namespace std;
const int N=2e5+5;
int n,r,q,sc[N],w[N],a[N],win[N],lose[N];
bool cmp(int a,int b)
{
	if(sc[a]!=sc[b]) return sc[a]>sc[b];
	return aw[a[i+1]])
   	    {
   	       sc[a[i]]++;
		   win[++win[0]]=a[i];	
		   lose[++lose[0]]=a[i+1];
		}
		else
		{
   	       sc[a[i+1]]++;
		   win[++win[0]]=a[i+1];	
		   lose[++lose[0]]=a[i];
		}
	  merge();
   }
   printf("%d",a[q]);
   
 return 0;  
}

你可能感兴趣的:(洛谷P1309 瑞士轮【排序】)