|洛谷|排序|P1309 瑞士轮

http://www.luogu.org/problem/show?pid=1309#sub

第一次快排,之后用a,b记录输赢的集合,赢了的和输了的的相对排序一致,用归并排序

#include
#include
#include
#include
#define ms(i,j) memset(i,j, sizeof i);
using namespace std;
struct ps
{
	int id;
	int score;
	int w;
}ans[200005], a[200005], b[200005];//第一次没开到200005丢了30分
bool cmp(ps const &i, ps const &j)
{
	if (i.score>j.score) return true;
	else if (i.scoreans[j+1].w)
			{
				ans[j].score++;
				b[++bi] = ans[j+1];
				a[++ai] = ans[j];
			}
			else
			{
				ans[j+1].score++;
				b[++bi] = ans[j];
				a[++ai] = ans[j+1];
			}
		}
		merge(a+1, a+n+1, b+1, b+n+1, ans+1, cmp);
	}
	printf("%d\n", ans[q].id);
    return 0;
}


你可能感兴趣的:(模拟,洛谷)