关于卡常
  • 板块灌水区
  • 楼主0htoAi
  • 当前回复6
  • 已保存回复6
  • 发布时间2020/11/5 19:12
  • 上次更新2023/11/5 08:55:27
查看原帖
关于卡常
335366
0htoAi楼主2020/11/5 19:12

这个代码还怎么卡常优化……卡在95分过不了

#include <bits/stdc++.h>
using namespace std;
bool a[1000005];
const int BUFFER_SIZE=1<<20;
char rb[BUFFER_SIZE],*rp=rb,*rt=rb;
inline char read_char(){
  return rp==rt?(rt=rb+fread(rb,1,BUFFER_SIZE,stdin),rp=rb,*rp++):*rp++;
}
inline int read_int(){
	register int x=0;
	char ch=read_char();
	while (ch!='-'&&(ch<'0'||ch>'9')){
		ch=read_char();
	}
	for (x=0;ch>='0'&&ch<='9';ch=read_char()){
		x=x*10+(ch-'0');
	}
	return x;
}
int main()
{
	int n=read_int(),m=read_int();
	register int t,s;
	while(n--)
	{
		s=read_int();
		t=s;
		while(t)
		{
			a[t]=true;
			t=t-1&s;
		}
	}
	while(m--)
	{
		t=read_int();
		if(a[t]==true)
		{
			printf("yes\n");
		}
		else
		{
			printf("no\n");
		}
	}
}
2020/11/5 19:12
加载中...