【bzoj4604】The kth maximum number

暴力

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
 
#define MAXN 50010
 
int a[MAXN];
int X[MAXN],Y[MAXN],W[MAXN];
 
int C,N,Q,L;
 
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
 
int main()
{
    N=read(),Q=read();
    while(Q--)
    {
        int ty=read();
        if (ty==1)
            X[C]=read(),Y[C]=read(),W[C++]=read();
        else
        {
            int xl=read(),yl=read(),xr=read(),yr=read(),k=read();
            for (int i=L=0;i<C;i++)
                if (xl<=X[i] && X[i]<=xr && yl<=Y[i] && Y[i]<=yr)
                    a[L++]=W[i];
            if (k>L)
                puts("NAIVE!ORZzyz.");
            else
            {
                nth_element(a,a+(L-k),a+L);
                printf("%d\n",a[L-k]);
            }
        }
    }
    return 0;
}

  

posted @ 2016-05-31 19:31  Yangjiyuan  阅读(365)  评论(0编辑  收藏  举报