萌新刚学OI,求助蜜汁RE
  • 板块题目总版
  • 楼主SIXIANG32
  • 当前回复12
  • 已保存回复12
  • 发布时间2020/9/27 13:43
  • 上次更新2023/11/5 12:32:06
查看原帖
萌新刚学OI,求助蜜汁RE
298549
SIXIANG32楼主2020/9/27 13:43
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#include<cmath>
using namespace std;
int f[1010000][21],n,m,a[100010];
map<int,int>year;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
inline void write(int x)
{
    char f[200];
    int tmp=x>0?x:-x,cnt=0;
    if(x<0)putchar('-');
    while(tmp>0)f[cnt++]=tmp%10+'0',tmp/=10;
    while(cnt>0)putchar(f[--cnt]);
    putchar('\n');
}
void ST()
{
	for(int i=1;i<=20;i++)
		for(int p=1;p<=n-(1<<i)+1;p++)
			f[p][i]=max(f[p][i-1],f[p+(1<<(i-1))][i-1]);
}
int ask(int l,int r)
{
	int Log=log2(r-l+1);
	return max(f[l][Log],f[r-(1<<Log)+1][Log]);
}
int main()
{
	n=read();
	for(int p=1,x,y;p<=n;p++)
	{
		cin>>x>>y;
		year[x]=p,f[p][0]=y;
	}
	ST();
	m=read();
	for(int p=1,x,y;p<=m;p++)
	{
		y=read(),x=read();
		int flag=0;
		if(x<=y)
		{
			cout<<"flase"<<endl;
			continue;
		}
		if(f[year[x]][0]>=f[year[y]][0])
		{
			cout<<"flase"<<endl;
			continue;
		}
		if(!year[y]||!year[x])
		{
			cout<<"maybe"<<endl;
			continue;
		}
		if(year[x]-year[y]!=x-y)
		{
			cout<<"maybe"<<endl;
			continue;
		}	
		if(ask(year[x],year[y])>=f[x][0])
		{
			cout<<"false"<<endl;
			continue;
		}
		cout<<"ture"<<endl;
	}
}

这是P2471的代码,还没有完全打完,就是个雏形,错误也很多,先别喷qwq
然后测试的时候蜜汁RE了,布吉岛为什么
求助qwq

2020/9/27 13:43
加载中...