QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#205617#7565. Harumachi Kazeucup-team052#TL 0ms0kbC++232.7kb2023-10-07 16:47:372023-10-07 16:47:39

Judging History

你现在查看的是最新测评结果

  • [2023-10-07 16:47:39]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-10-07 16:47:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
#define N 20005
int n,Q,B;
const int SIZ=125;
int Add(int x,int y)
{
#ifdef wasa855
	return x+y;
#endif
	printf("A %d %d\n",x,y); fflush(stdout);
	return read();
}
int Cmp(int x,int y)
{
#ifdef wasa855
	return x<y?x:y;
#endif
	printf("C %d %d\n",x,y); fflush(stdout);
	return read();
}
struct Arr
{
	int a[N];
	int bs[N],sum[N],pre[N];
	int cnt;
	void init()
	{
		cnt=0;
		for(int i=0;i<n;i+=SIZ)
		{
			pre[i]=a[i];
			sum[cnt]=pre[i];
			for(int j=1;i+j<n&&j<SIZ;j++) pre[i+j]=Add(pre[i+j-1],a[i+j]),sum[cnt]=pre[i+j];
			cnt++;
			bs[cnt]=Add(bs[cnt-1],sum[cnt]);
		}
	}
	int qry(int i)
	{
		if(i==n) return -1;
		return Add(bs[i/SIZ],pre[i]);
	}
	void upd(int i,int v)
	{
		a[i]=v;
		// printf("* %d %d\n",i,v);
		int tw=i/SIZ;
		pre[tw*SIZ]=a[tw*SIZ];
		sum[tw]=pre[tw*SIZ];
		for(int j=1;j<SIZ&&tw*SIZ+j<n;j++) pre[tw*SIZ+j]=Add(pre[tw*SIZ+j-1],a[tw*SIZ+j]),sum[tw]=pre[tw*SIZ+j];
		for(int i=1;i<=cnt;i++) bs[i]=Add(bs[i-1],sum[i]);
	}
}a,b;
int op[N],t[N],pos[N],x[N];
signed main()
{
	cin>>n>>Q>>B;
	for(int i=0;i<n;i++) a.a[i]=read();
	for(int i=0;i<n;i++) b.a[i]=read();
	for(int i=1;i<=Q;i++)
	{
		op[i]=read();
		if(op[i]==1) t[i]=read(),pos[i]=read()-1,x[i]=read();
		else t[i]=read();
	}
	a.init(),b.init();
	vector<int> ANS;
	for(int i=1;i<=Q;i++)
	{
		if(op[i]==1)
		{
			if(t[i]==1) a.upd(pos[i],x[i]);
			else b.upd(pos[i],x[i]);
		}
		else
		{
			if(t[i]==2*n)
			{
				int A=a.qry(n-1),B=b.qry(n-1);
				if(Cmp(A,B)==A) ANS.pb(B);
				else ANS.pb(A);
				continue;
			}
			int L=min(n-1,t[i]-2);
			int l=0,r=min(n-1,t[i]-2),ans=L+1;
			while(l<=r)
			{
				int mid=(l+r)/2;
				if(t[i]-mid-2>=n)
				{
					l=mid+1;
					continue;
				}
				int A=a.qry(mid),B=b.qry(t[i]-mid-2);
				if(Cmp(A,B)==B) ans=mid,r=mid-1;
				else l=mid+1;
			}
			if(ans==n) ANS.pb(b.qry(t[i]-n-1));
			else
			{
				int A=a.qry(ans),B=b.qry(t[i]-ans-1);
				// printf("%d %d - %d %d\n",ans,t[i]-ans-1,A,B);
				ANS.pb(Cmp(A,B));
			}
		}
		// for(int i=0;i<n;i++) printf("%d%c",b.qry(i)," \n"[i==n-1]);
	}
	printf("! %d\n",(int)ANS.size());
	print(ANS);
	return 0;
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

2 3 2
288230376151711744 864691128455135232
1441151880758558720 2017612633061982208
2 3
1 2 2 2594073385365405696
2 3
0
0
0
0
0
0
0
0

output:

A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
C 0 0
A 0 0
C 0 -1

result: