题面

题面

题解

如果2个人可以互相战胜,那么我们连一条无向边,于是最后会剩下t个联通块,其中每对联通块之间都有严格的大小关系(a.max < b.min),因此我们每插入一个点就相当于合并一段连续的块,其中边界(无法继续合并的地方)是第一个严格比它小的和第一个严格比它大的。

#include<bits/stdc++.h>
using namespace std;
#define R register int
#define LL long long
#define ld double
#define AC 15
#define ac 101000 int n, K;
inline int read()
{
int x = 0;char c = getchar();
while(c > '9' || c < '0') c = getchar();
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x;
} inline void upmin(int &a, int b) {if(b < a) a = b;}
inline void upmax(int &a, int b) {if(b > a) a = b;} struct node{
int maxn[AC], minn[AC], Size; friend bool operator < (node a, node b)
{
for(R i = 1; i <= K; i ++)
if(a.maxn[i] > b.minn[i]) return 0;
return 1;//只有b严格大于a才返回true,即Min(b) > Max(a)
} inline void merge(node a)
{
Size += a.Size;
for(R i = 1; i <= K; i ++)
upmax(maxn[i], a.maxn[i]), upmin(minn[i], a.minn[i]);
}
};
set <node> S;
set <node> :: iterator q[ac]; void pre()
{
n = read(), K = read();
} void work()
{
for(R i = 1; i <= n; i ++)
{
node x;
x.Size = 1;
for(R j = 1; j <= K; j ++) x.maxn[j] = x.minn[j] = read();
set <node> :: iterator last = S.lower_bound(x);
set <node> :: iterator Next = S.upper_bound(x);
set <node> :: iterator it;
int tot = 0;
for(it = last; it != Next; it ++) q[++ tot] = it;
for(R j = 1; j <= tot; j ++) x.merge(*q[j]), S.erase(q[j]);//将中间的点不断合并进来并删除
S.insert(x);
printf("%d\n", S.rbegin() -> Size);
}
} int main()
{
freopen("in.in", "r", stdin);
pre();
work();
fclose(stdin);
return 0;
}

CF878C Tournament set 图论的更多相关文章

  1. 【CF878C】Tournament set+并查集+链表

    [CF878C]Tournament 题意:有k个项目,n个运动员,第i个运动员的第j个项目的能力值为aij.一场比赛可以通过如下方式进行: 每次选出2个人和一个项目,该项目能力值高者获胜,败者被淘汰 ...

  2. 图论 竞赛图(tournament)学习笔记

    竞赛图(tournament)学习笔记 现在只是知道几个简单的性质... 竞赛图也叫有向完全图. 其实就是无向完全图的边有了方向. ​ 有一个很有趣的性质就是:一个tournament要么没有环,如果 ...

  3. [leetcode] 题型整理之图论

    图论的常见题目有两类,一类是求两点间最短距离,另一类是拓扑排序,两种写起来都很烦. 求最短路径: 127. Word Ladder Given two words (beginWord and end ...

  4. Codeforces CF#628 Education 8 A. Tennis Tournament

    A. Tennis Tournament time limit per test 1 second memory limit per test 256 megabytes input standard ...

  5. 并查集(图论) LA 3644 X-Plosives

    题目传送门 题意:训练指南P191 分析:本题特殊,n个物品,n种元素则会爆炸,可以转移到图论里的n个点,连一条边表示u,v元素放在一起,如果不出现环,一定是n点,n-1条边,所以如果两个元素在同一个 ...

  6. Rock-Paper-Scissors Tournament[HDU1148]

    Rock-Paper-Scissors TournamentTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...

  7. NOIp 2014 #2 联合权值 Label:图论 !!!未AC

    题目描述 无向连通图G 有n 个点,n - 1 条边.点从1 到n 依次编号,编号为 i 的点的权值为W i ,每条边的长度均为1 .图上两点( u , v ) 的距离定义为u 点到v 点的最短距离. ...

  8. CF 628A --- Tennis Tournament --- 水题

    CF 628A 题目大意:给定n,b,p,其中n为进行比赛的人数,b为每场进行比赛的每一位运动员需要的水的数量, p为整个赛程提供给每位运动员的毛巾数量, 每次在剩余的n人数中,挑选2^k=m(m & ...

  9. ural 1218. Episode N-th: The Jedi Tournament

    1218. Episode N-th: The Jedi Tournament Time limit: 1.0 secondMemory limit: 64 MB Decided several Je ...

随机推荐

  1. 10_SpringBoot集成TkMybatis插件

    10_SpringBoot集成TkMybatis插件 明天你好向前奔跑 关注  0.5 2018.09.11 11:15 字数 163 阅读 3794评论 0喜欢 3 @Author Jacky Wa ...

  2. iOS上架被拒理由及相关解决方案记录

    注:苹果客服中国区电话:4006 701 855 最近公司上线一个电动车工具类项目,被拒无数次,今天上架了,记录一下 01 苹果拒绝理由(内购和后台定位) We noticed that your a ...

  3. mysql学习----支持Emoji表情

    但发现了一个问题,iPhone上有Emoji表情,插入Mysql时失败了,报如下异常: java.sql.SQLException: Incorrect string value: '\xF0\x9F ...

  4. TeamViewer卡在正在初始化显示参数

    在windows的mstsc远程桌面中打开teamviewer,远程桌面开着的时候可以连接teamviewer,但是当我断开mstsc之后,再用teamviewer连就连接不上了,一直都是正在初始化显 ...

  5. 使用Photon引擎进行unity网络游戏开发(一)——Photon引擎简介

    使用Photon引擎进行unity网络游戏开发(一)--Photon引擎简介 Photon PUN Unity 网络游戏开发 Photon引擎简介: 1. 服务器引擎: 服 务 器 引 擎 介 绍 服 ...

  6. eclipse 简单操作

    1.设置字体: windows --> preferences --> general --> Colors and Fonts --> Basic --> 双击 Tex ...

  7. ASP.NET 异步Web API + jQuery Ajax 文件上传代码小析

    该示例中实际上应用了 jquery ajax(web client) + async web api 双异步. jquery ajax post $.ajax({ type: "POST&q ...

  8. Scrum立会报告+燃尽图(Beta阶段第二周第五次)

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2413 项目地址:https://coding.net/u/wuyy694 ...

  9. 20172321 2018-2019《Java软件结构与数据结构》第三周学习总结

    教材学习内容总结 第五章 5.1概述 队列是一种线性集合,其元素从一端加入,从另一端删除:队列的处理方式是先进先出(First in First out). 与栈的比较(LIFO) 栈是一端操作,先进 ...

  10. 路由器DMZ功能

    环境描述 172.17* 校园网 实验室路由器接入校园网,通过nat分化出网段 192.168.. 实验过程 主机A(windows)接入路由器(192.168.1.110),主机B(Ubuntu)接 ...