The Preliminary Contest for ICPC Asia Xuzhou 2019 E. XKC's basketball team

There are nnn points in an array with index from 111 to nnn, and there are two operations to those points.

1: 1 x1 \ x1 x marking the point xxx is not available

2: 2 x2 \ x2 x query for the index of the first available point after that point (including xxx itself) .

 

Input

nqn\quad qnq

z1x1z_1 \quad x_1z1​x1​

⋮\vdots⋮

zqxqz_q\quad x_qzq​xq​

qqq is the number of queries, zzz is the type of operations, and xxx is the index of operations. 1≤x<n<1091≤x<n<10^91≤x<n<109, 1≤q<1061 \leq q<10^6 1≤q<106 and zzz is 111 or 222

Output

Output the answer for each query.

样例输入

5 3
1 2
2 2
2 1

样例输出

3
1

题意:每个人都有一个能力值ai,假如ai+m小于aj而且i<J那他就生气 然后生气度为j-i-1 找到每个人的最大生气度

思路:把所有数都放到优先队列,然后从后往前,从n到1,a[i]-m与队列顶部元素比较,顶部元素比a[i]小且坐标小于i,那么他们配对,弹出顶部元素,然后继续比较,直到顶部元素大于a[i],i--。最后剩下未弹出的就是输出-1

#include<stdio.h>
#include<math.h>
#include<vector>
#include<cstring>
#include<queue>
#include<iostream>
#include<algorithm>
#define maxn 7500000
using namespace std;
#include <unordered_map>
#include<map>
unordered_map<int,int>fa;
unordered_map<int,int>q1;
void init()
{
    q1.clear();
    fa.clear();
    /*for(int i=1;i<=maxn-100;i++)
    {
        fa[i]=i;
        //d[i]=1;
    }*/
}
int Find(int x)
{
    if(fa.count(x)==0) return x;
    fa[x]=Find(fa[x]);
    return fa[x];
}
void Merge(int x,int y)
{
    x=Find(x);y=Find(y);
    if(x!=y)
    {
        if(x>y)
        {
            fa[y]=x;
            //d[y]+=d[x];
        }
        else fa[x]=y;
    }
}
int main()
{
    int n,q;
    init();
    scanf("%d %d",&n,&q);
    while(q--)
    {
        int z1,x1;
        scanf("%d %d",&z1,&x1);
        //if(q!=1) printf("")
        if(z1==1)
        {
            q1[x1]=1;
            if(q1.count(x1-1)!=0)
            {
                //printf("x1=%d -1\n",x1);
                Merge(x1,x1-1);
            }
            if(q1.count(x1+1)!=0)
            {
                //printf("x1=%d +1\n",x1);
                Merge(x1,x1+1);

            }
        }
        else
        {
            int w=Find(x1);
            if(w==x1)
            {
                if(q1.count(w)!=0)
                {
                    if(w==n) printf("-1\n");
                    else printf("%d\n",x1+1);
                }
                else printf("%d\n",x1);
            }
            else
            {
                if(w==n) printf("-1\n");
                else printf("%d\n",w+1);
            }
        }
    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure, I'd be happy to give you some ideas for organizing a speech contest. Here are some suggestions: 1. Determine the theme and rules: Decide on the theme of the contest and the rules for participants. Will it be an open topic, or will there be a specific theme? What is the maximum length of the speech? Will there be any specific guidelines for language or content? 2. Decide on the judging criteria: Determine how the speeches will be evaluated. Will judges be looking for content, delivery, or both? Will there be a score sheet or rubric that judges will use to score the speeches? 3. Recruit judges: Find people who are qualified to judge the speeches. Ideally, they should have experience in public speaking or have a background in the theme of the contest. 4. Promote the contest: Advertise the contest to potential participants, such as students, professionals, or members of a specific community. Use social media, flyers, and other methods to get the word out. 5. Registration and selection: Set a deadline for registration and selection of participants. Consider having a preliminary round to narrow down the field before the final competition. 6. Prepare the venue: Ensure that the venue is suitable for the contest. Make sure that there is adequate seating, sound equipment, and lighting for the speakers. 7. Hold the contest: Set a date and time for the contest, and make sure that all participants and judges are aware of the schedule. Encourage audience participation and provide refreshments. 8. Award ceremony: After the contest, hold an award ceremony to recognize the winners and participants. Provide certificates or other prizes to the top performers. I hope these ideas help you in organizing a successful speech contest!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值