QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#217031#7522. Sequence ShiftExplodingKonjacWA 48ms10508kbC++205.1kb2023-10-16 11:48:332023-10-16 11:48:33

Judging History

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

  • [2023-10-16 11:48:33]
  • 评测
  • 测评结果:WA
  • 用时:48ms
  • 内存:10508kb
  • [2023-10-16 11:48:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define OPENIOBUF

namespace FastIO
{

class FastIOBase
{
 protected:
#ifdef OPENIOBUF
	static const int BUFSIZE=1<<16;
	char buf[BUFSIZE+1];
	int buf_p=0;
#endif
	FILE *target;
	FastIOBase(FILE *f): target(f){}
	~FastIOBase()=default;
 public:
#ifdef OPENIOBUF
	virtual void flush()=0;
#endif
};

class FastOutput final: public FastIOBase
{
 private:
	void __putc(char x)
	{
#ifdef OPENIOBUF
		if(buf[buf_p++]=x,buf_p==BUFSIZE) flush();
#else
		putc(x,target);
#endif
	}
	template<typename T>
	void __write(T x)
	{
		char stk[numeric_limits<T>::digits10+1],*top=stk;
		if(x<0) return __putc('-'),__write(-x);
		do *(top++)=x%10,x/=10; while(x);
		for(;top!=stk;__putc(*(--top)+'0'));
	}
 public:
	FastOutput(FILE *f=stdout): FastIOBase(f) {}
#ifdef OPENIOBUF
	~FastOutput() { flush(); }
	void flush() { fwrite(buf,1,buf_p,target),buf_p=0; }
#endif
	FastOutput &operator <<(char x)
	{ return __putc(x),*this; }
	FastOutput &operator <<(const char *s)
	{ for(;*s;__putc(*(s++)));return *this; }
	FastOutput &operator <<(const std::string &s)
	{ return (*this)<<s.c_str(); }
	template<typename T>
	std::enable_if_t<std::is_integral<T>::value,FastOutput&> operator <<(const T &x)
	{ return __write(x),*this; }
	template<typename ...T>
	void writesp(const T &...x)
	{ std::initializer_list<int>{(this->operator<<(x),__putc(' '),0)...}; }
	template<typename ...T>
	void writeln(const T &...x)
	{ std::initializer_list<int>{(this->operator<<(x),__putc('\n'),0)...}; }
	template<typename Iter>
	void writesp(Iter begin,Iter end)
	{ while(begin!=end) (*this)<<*(begin++)<<' '; }
	template<typename Iter>
	void writeln(Iter begin,Iter end)
	{ while(begin!=end) (*this)<<*(begin++)<<'\n'; }
}qout;

class FastInput final: public FastIOBase
{
 private:
	bool __eof;
 public:
	FastInput(FILE *f=stdin): FastIOBase(f),__eof(false)
#ifdef OPENIOBUF
	{ buf_p=BUFSIZE; }
	void flush() { buf[fread(buf,1,BUFSIZE,target)]=EOF,buf_p=0; }
	bool eof()const { return buf[buf_p]==EOF; }
#else
	{}
	bool eof()const { return feof(target); }
#endif
	char get()
	{
		if(__eof) return EOF;
#ifdef OPENIOBUF
		if(buf_p==BUFSIZE) flush();
		char ch=buf[buf_p++];
#else
		char ch=getc(target);
#endif
		return ~ch?ch:(__eof=true,EOF);
	}
	void unget(char c)
	{
		__eof=false;
#ifdef OPENIOBUF
		buf[--buf_p]=c;
#else
		ungetc(c,target);
#endif
	}
	explicit operator bool()const { return !__eof; }
	FastInput &operator >>(char &x)
	{ while(isspace(x=get()));return *this; }
	template<typename T>
	std::enable_if_t<std::is_integral<T>::value,FastInput&> operator >>(T &x)
	{
		char ch,sym=0;x=0;
		while(isspace(ch=get()));
		if(__eof) return *this;
		if(ch=='-') sym=1,ch=get();
		for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=get());
		return unget(ch),sym?x=-x:x,*this;
	}
	FastInput &operator >>(char *s)
	{
		while(isspace(*s=get()));
		if(__eof) return *this;
		for(;!isspace(*s) && !__eof;*(++s)=get());
		return unget(*s),*s='\0',*this;
	}
	FastInput &operator >>(std::string &s)
	{
		char str_buf[(1<<8)+1]={0},*p=str_buf;
		char *const buf_end=str_buf+(1<<8);
		while(isspace(*p=get()));
		if(__eof) return *this;
		for(s.clear(),p++;;p=str_buf)
		{
			for(;p!=buf_end && !isspace(*p=get()) && !__eof;p++);
			if(p!=buf_end) break;
			s.append(str_buf);
		}
		unget(*p),*p='\0',s.append(str_buf);
		return *this;
	}
	template<typename ...T>
	void read(T &...x)
	{ std::initializer_list<int>{(this->operator>>(x),0)...}; }
	template<typename Iter>
	void read(Iter begin,Iter end)
	{ while(begin!=end) (*this)>>*(begin++); }
}qin;

} // namespace FastIO
using FastIO::qin,FastIO::qout;

using LL=long long;
using LD=long double;
using UI=unsigned int;
using ULL=unsigned long long;
constexpr int INF=1e9;

#ifndef DADALZY
#define FILEIO(file) freopen(file".in","r",stdin),freopen(file".out","w",stdout)
#define LOG(...) void()
#else
#define FILEIO(file)
#define LOG(...) fprintf(stderr,__VA_ARGS__)
#endif

int n,m,a[1000005],b[1000005],ord[1000005],ans[3000005];

int main()
{
	qin>>n>>m,m+=n;
	qin.read(a+1,a+n+1);
	qin.read(b+1,b+n+1);
	int k=[&] {
		auto f=[](LD x) {
			return x+LL(m-n+1)*n*pow(1-x/LL(n*m),n);
		};
		LD l=0,r=LL(n)*m;
		while(r-l>1e-3)
		{
			LD lm=l+(r-l)/3,rm=r-(r-l)/3;
			if(f(lm)<=f(rm)) r=rm;
			else l=lm;
		}
		LL res=sqrt(2ll*n*m)*sqrt(l)/(n+m)+0.5;
		return min(res,(LL)n);
	}();
	iota(ord+1,ord+n+1,1);
	sort(ord+1,ord+n+1,[](int x,int y){ return a[x]>a[y]; });
	priority_queue<int,vector<int>,greater<>> q;
	for(int i=1;i<=n;i++)
	{
		q.push(b[i]);
		ans[0]=max(ans[0],a[i]+b[i]);
	}
	while(q.size()>k) q.pop();
	int lst=ans[0];
	qout<<ans[0]<<'\n';
	for(int i=-n,x;i<=m-n;i++)
	{
		if(i<=0) x=b[m+i];
		else
		{
			qin>>x,x^=lst;
			q.push(x);
			while(q.size()>k) q.pop();
		}
		int lim=a[ord[k]]+q.top();
		for(int j=1;j<=n;j++)
		{
			int p=ord[j];
			if(a[p]+x<lim) break;
			int dt=i+n-p;
			if(dt>0) ans[dt]=max(ans[dt],a[p]+x);
		}
		if(i>0)
		{
			if(!ans[i])
				for(int j=1;j<=n;j++)
					ans[i]=max(ans[i],a[j]+b[j+i]);
			qout<<ans[i]<<'\n';
			lst=ans[i];
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 9844kb

input:

5 3
1 4 3 2 5
7 5 8 3 2
3
6
4

output:

11
13
16
25

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 9996kb

input:

1 0
103509429
823330096

output:

926839525

result:

ok single line: '926839525'

Test #3:

score: 0
Accepted
time: 1ms
memory: 9780kb

input:

1 1
576560149
691846236
1156187222

output:

1268406385
835582012

result:

ok 2 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 9744kb

input:

1 10
700282491
332230980
90825676
1630266999
644973380
262379760
2122877054
1851957134
1370195232
110993724
1319359505
1883523208

output:

1032513471
1654684398
759763732
888538827
1695749302
1163465539
1425605448
789576931
1397740634
1202288326
1638577353

result:

ok 11 lines

Test #5:

score: -100
Wrong Answer
time: 48ms
memory: 10508kb

input:

1000 100000
438001359 929744877 710148392 323984311 727016267 323629255 495752276 309120511 312675195 717795522 937464489 624952229 444774478 829169766 707441777 609125148 25459976 849166512 716162953 882416779 189669312 135698832 632796131 592794700 569746403 231058028 389412868 824283503 801480367...

output:

1962871590
1986083253
1967509108
1973351244
1974354421
1956371849
1976394149
1995721753
1946870160
1984280254
1961237540
1955903880
1784310112
1937726835
1993563403
1927000559
1804260369
1979133252
1767128688
1941301401
1922284543
1846227641
1963663583
1837388959
1933606347
1781408081
1806983256
194...

result:

wrong answer 13th lines differ - expected: '1944520591', found: '1784310112'