我是靠谱客的博主 复杂狗,这篇文章主要介绍2021百度之星Astar 1006毒瘤数据结构,现在分享给大家,希望可以做个参考。

Astar 1006毒瘤数据结构

只需要每次加入的时候维护一下最前面从1开始连续的1的个数即可,用时:9min

#include<iostream>
#include<algorithm>
#include<cstring>
#include<string.h>
#include<cstdio>
#define MAXN 5000010
using namespace std; 

int a[MAXN];
int n;
int op,pos;

int main(){
	int poi=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&op,&pos);
		if(op==1){
			a[pos]=1;
			while(a[poi]==1) poi++;
		}
		else if(op==2){
			bool flag=a[pos]==1;
			a[pos]=1;
			int p=poi;
			while(a[poi]==1) poi++;
			printf("%dn",poi);
			poi=p;
			a[pos]=flag;			
		}
	}
	return 0;
}


最后

以上就是复杂狗最近收集整理的关于2021百度之星Astar 1006毒瘤数据结构的全部内容,更多相关2021百度之星Astar内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(148)

评论列表共有 0 条评论

立即
投稿
返回
顶部