https://i2.wp.com/eblogarithm.com/wp-content/uploads/2017/11/Codeforces-Round-443-Div-2-problem-E-Tournament-Solution-In-CC1.png?fit=640%2C360

Codeforces Round #443 (Div. 2), problem: (E) Tournament Solution In C/C++

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
int n,k;
struct node
{
int maxx[15],minn[15],sz;
node()
{
int x;sz = 1;
for(int i = 1; i <= k ; i ++)
{
scanf(“%d”,&x);
minn[i] = maxx[i] = x;
}
}
bool operator<(const node &nd)const
{
for(int i = 1; i <= k; i ++)
if(maxx[i] > nd.minn[i]) return false;
return true;
}
void merge(const node &nd)
{
for(int i = 1; i <= k; i ++){
minn[i] = min(minn[i],nd.minn[i]);
maxx[i] = max(maxx[i],nd.maxx[i]);
}
sz += nd.sz;
}
};

set<node> tr;
int main()
{

//freopen(“1.in”,”r”,stdin);
scanf(“%d%d”,&n,&k);
set<node>::iterator ub,lb;
for(int i = 1; i <= n;i ++)
{
node nd = node();
lb = tr.lower_bound(nd);
ub = tr.upper_bound(nd);
while(lb!=ub){
nd.merge(*lb);
tr.erase(lb++);
}
tr.insert(nd);
printf(“%d\n”,(tr.rbegin()) -> sz);
}
}

(Visited 6 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: