The tree sets the tree "bzoj3262" The flower opens in the MO

Source: Internet
Author: User

/*

"bzoj3262" on the flower OpenJune 19, 2014 1,2430 Description there are n flowers, each flower has three attributes: Flower shape (s), color (c), Odor (m), and three integers. Now, to rate each flower, the level of a flower is the number of flowers that it can surpass. Define a flower a than another flower B to be beautiful, when and only if sa>=sb,ca>=cb,ma>=mb. Obviously, two flowers may have the same properties. The number of flowers to be rated for each level needs to be counted. Input The First behavior n,k (1 <= N <= 100,000, 1 <= K <= 200,000), respectively, represents the number of flowers and the maximum attribute value. The following n lines, three integers per line si, CI, mi (1 <= si, CI, mi <= K), representing the properties of the flower of the IOutput contains n rows, each representing a rating of 0 ... N-1 the number of flowers per level. */ //Tree Set tree CDQ Division will not //card when the function of the large field of view is not recognized, gave me the N-Times re, the gas dead me ....... .......

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#define M 5000005
using namespace Std;
struct SHU
{
int x, y, Z;
}A[100005];
int n,m,sum[100005],ans[100005],sz,root[200005],w[m],v[m],sz1[m],lr[m],rr[m],rou[m];
int tmp;
BOOL CMP (SHU A1,shu a2)
{
if (A1.X==A2.X&AMP;&AMP;A1.Y==A2.Y)
Return a1.z<a2.z;
if (a1.x==a2.x)
Return a1.y<a2.y;
Return a1.x<a2.x;
}
void Update (int A1)
{
SZ1[A1]=SZ1[LR[A1]]+SZ1[RR[A1]]+W[A1];
}
void Zuo (int &a1)
{
int T=LR[A1];
LR[A1]=RR[T];
RR[T]=A1;
Update (A1);
Update (t);
a1=t;
}
void You (int &a1)
{
int T=RR[A1];
RR[A1]=LR[T];
LR[T]=A1;
Update (A1);
Update (t);
a1=t;
}
void JIAA (int &a1,int A2)
{
if (a1==0)
{
sz++;
A1=sz;
V[A1]=A2;
Sz1[a1]=1;
W[a1]=1;
Rou[a1]=rand ();
Return
}
sz1[a1]++;
if (V[A1]==A2)
{
w[a1]++;
Return
}
if (V[A1]&GT;A2)
{
JIAA (LR[A1],A2);
if (ROU[LR[A1]]&LT;ROU[A1])
Zuo (A1);
}
Else
{
JIAA (RR[A1],A2);
if (ROU[RR[A1]]&LT;ROU[A1])
You (A1);
}
}
void Jia (int a1,int A2)
{
for (; a1<=m;a1+= (a1& (-A1)))
JIAA (ROOT[A1],A2);
}
void Askk (int a1,int A2)
{
if (a1==0)
Return
if (V[A1]==A2)
{
TMP+=W[A1]+SZ1[LR[A1]];
Return
}
if (V[A1]&GT;A2)
ASKK (LR[A1],A2);
Else
{
TMP+=W[A1]+SZ1[LR[A1]];
ASKK (RR[A1],A2);
}
Return
}
void Ask (int a1,int A2)
{
for (; a1;a1-= (a1& (-A1)))
ASKK (ROOT[A1],A2);
}
int main ()
{
scanf ("%d%d", &n,&m);
for (int i=1;i<=n;i++)
scanf ("%d%d%d", &a[i].x,&a[i].y,&a[i].z);
Sort (a+1,a+n+1,cmp);
for (int i=1;i<=n;i++)
{
if (a[i].y==a[i+1].y&&a[i].z==a[i+1].z&&a[i].x==a[i+1].x&&i!=n)
sum[i+1]+=sum[i]+1;
Else
{
Tmp=0;
Ask (A[I].Y,A[I].Z);
ans[tmp]+=sum[i]+1;
}
Jia (a[i].y,a[i].z);
}
for (int i=0;i<n;i++)
printf ("%d\n", Ans[i]);
return 0;
}

The tree sets the tree "bzoj3262" The flower opens in the MO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.