Codeforces Round #443 (Div. 1) C. Tournament(瞎搞???)

题目链接:http://codeforces.com/contest/878/problem/C


我好像。。。是个辣鸡啊?


明显是维护一个图,如果a能打过b,则a到b连一条边,将成环的人全部缩成一个点,然后对于k项运动,记录这个环中每一项运动的最大最小值,然后我们就可以O(k)的时间内判断两个环的大小关系,如果a环能击败b环,b环也能击败a环,就合并两个环,然后set维护,暴力合并就行了。


学习了stl的新姿势啊?


代码:

#include<bits/stdc++.h>
using namespace std;
const int MAXN=5e4+5;
struct node
{
	vector<int> lo,hi;
	int sz;
	node(){}
	node(int *a,int *b):sz(1),lo(a,b),hi(a,b){}
	bool operator < (const node &o)const
	{
		for(int i=0;i<lo.size();i++)
		{
			if(hi[i]>=o.lo[i])
				return false;
		}
		return true;
	}
	void merge(const node &o)
	{
		sz+=o.sz;
		for(int i=0;i<lo.size();i++)
		{
			lo[i]=min(lo[i],o.lo[i]);
			hi[i]=max(hi[i],o.hi[i]);
		}
	}
};
int n,k,s[15];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	set<node> G;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<k;j++)
		{
			scanf("%d",&s[j]);
		}
		node player(s,s+k);
		auto i0=G.lower_bound(player),i1=G.upper_bound(player);
		while(i0!=i1)
		{
			player.merge(*i0);
			i0=G.erase(i0);
		}
		G.insert(player);
		printf("%d\n",G.rbegin()->sz);
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值