关于今晚ABC的D题
  • 板块灌水区
  • 楼主Sterelogue
  • 当前回复8
  • 已保存回复8
  • 发布时间2022/4/16 21:56
  • 上次更新2023/10/28 03:32:51
查看原帖
关于今晚ABC的D题
531939
Sterelogue楼主2022/4/16 21:56

请问该怎么做啊啊啊啊啊
我的代码:

#include<cstdio>
using namespace std;
int n,a[200001],q;
struct queries{
	int l,r,x,ans;
}query[200001];
inline 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<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
inline void print(int x) 
{
    char F[200];
    int tmp=x>0?x:-x ;
    if(x<0)putchar('-') ;
    int cnt=0 ;
    while(tmp>0)
    {
        F[cnt++]=tmp%10+'0';
        tmp/=10;
    }
    while(cnt>0)putchar(F[--cnt]) ;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	q=read();
	for(int i=1;i<=q;i++)
	{
		query[i].l=read(),query[i].r=read(),query[i].x=read();
		for(int j=query[i].l;j<=query[i].r;j++)
		{
			if(a[j]==query[i].x) query[i].ans++;
		}
	}
	for(int i=1;i<=q;i++)
		printf("%d\n",query[i].ans);
	return 0;
}

TLE了11个点

2022/4/16 21:56
加载中...