QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#78317#5236. Wersja dla profesjonalistów [A]ExplodingKonjac0 3ms3540kbC++174.3kb2023-02-17 19:50:312023-02-17 19:50:33

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-17 19:50:33]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:3540kb
  • [2023-02-17 19:50:31]
  • 提交

answer

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

namespace FastIO
{

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

class FastOutput: public FastIOBase
{
#ifdef OPENIOBUF
 public:
	inline void flush()
		{ fwrite(buf,1,buf_p,target),buf_p=0; }
#endif
 protected:
	inline void __putc(char x)
	{
#ifdef OPENIOBUF
		if(buf[buf_p++]=x,buf_p==BUFSIZE)flush();
#else
		putc(x,target);
#endif
	}
	template<typename T>
	inline void __write(T x)
	{
		static char stk[64],*top;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
	inline void setTarget(FILE *f) { this->flush(),target=f; }
	~FastOutput(){ flush(); }
#else
	inline void setTarget(FILE *f) { target=f; }
#endif
	template<typename ...T>
	inline void writesp(const T &...x)
		{ initializer_list<int>{(this->operator<<(x),__putc(' '),0)...}; }
	template<typename ...T>
	inline void writeln(const T &...x)
		{ initializer_list<int>{(this->operator<<(x),__putc('\n'),0)...}; }
	inline FastOutput &operator <<(char x)
		{ return __putc(x),*this; }
	inline FastOutput &operator <<(const char *s)
		{ for(;*s;__putc(*(s++)));return *this; }
	inline FastOutput &operator <<(const string &s)
		{ return (*this)<<s.c_str(); }
	template<typename T,typename=typename enable_if<is_integral<T>::value>::type>
	inline FastOutput &operator <<(const T &x)
		{ return __write(x),*this; }
}qout;

class FastInput: public FastIOBase
{
#ifdef OPENIOBUF
 public:
	inline void flush()
		{ buf[fread(buf,1,BUFSIZE,target)]='\0',buf_p=0; }
#endif
 protected:
	inline char __getc()
	{
#ifdef OPENIOBUF
		if(buf_p==BUFSIZE) flush();
		return buf[buf_p++];
#else
		return getc(target);
#endif
	}
 public:
#ifdef OPENIOBUF
	FastInput(FILE *f=stdin): FastIOBase(f){ buf_p=BUFSIZE; }
	inline void setTarget(FILE *f) { this->flush(),target=f; }
#else
	FastInput(FILE *f=stdin): FastIOBase(f){}
	inline void setTarget(FILE *f) { target=f; }
#endif
	inline char getchar() { return __getc(); }
	template<typename ...T>
	inline void read(T &...x)
		{ initializer_list<int>{(this->operator>>(x),0)...}; }
	inline FastInput &operator >>(char &x)
		{ while(isspace(x=__getc()));return *this; }
	template<typename T,typename=typename enable_if<is_integral<T>::value>::type>
	inline FastInput &operator >>(T &x)
	{
		static char ch,sym;x=sym=0;
		while(isspace(ch=__getc()));
		if(ch=='-') sym=1,ch=__getc();
		for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=__getc());
		return sym?x=-x:x,*this;
	}
	inline FastInput &operator >>(char *s)
	{
		while(isspace(*s=__getc()));
		for(;!isspace(*s) && *s && ~*s;*(++s)=__getc());
		return *s='\0',*this;
	}
	inline FastInput &operator >>(string &s)
	{
		char str_buf[(1<<8)+1],*p=str_buf;
		char *const buf_end=str_buf+(1<<8);
		while(isspace(*p=__getc()));
		for(s.clear(),p++;;p=str_buf)
		{
			for(;p!=buf_end && !isspace(*p=__getc()) && *p && ~*p;p++);
			*p='\0',s.append(str_buf);
			if(p!=buf_end) break;
		}
		return *this;
	}
}qin;

} // namespace FastIO
using namespace FastIO;

using LL=long long;
using LD=long double;
using UI=unsigned int;
using ULL=unsigned long long;

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

void multi(LL x,const string &s,string &res)
{
	int now=x%9;
	if(now>1) res+=(now+'0');
	if(now>0) res+=s;
	if(x<9) return;
	res+="9[",multi(x/9,s,res),res+="]";
}
void solve(LL n,string &res,bool has_edge=true)
{
	if(n==1) res+="BD";
	else if(n%2==0)
	{
		multi(n,"B",res);
		multi(n-1,"[DF]",res);
		res+="D",solve(n-1,res,false);
	}
	else
	{
		string tmp;
		multi(n,"B",res),res+="D";
		tmp+="[",multi(n/2,"D",tmp);
		multi(n/2-1,"[FB]",tmp),tmp+="F]";
		multi(n/2,tmp,res);
		multi(n/2,"B",res);
		multi(n-1,"[FD]",res);
		res+="2[",solve(n/2,res,false),res+="]";
	}
	if(has_edge) multi(n,"F",res);
}
LL n;
int main()
{
	qin>>n;
	string ans;
	solve(n,ans);
	qout<<ans;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 1
Accepted
time: 2ms
memory: 3436kb

input:

1

output:

BDF

result:

ok correct (length = 3)

Test #2:

score: -1
Wrong Answer
time: 2ms
memory: 3328kb

input:

2

output:

2B[DF]DBD2F

result:

wrong answer invalid output

Subtask #2:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 2ms
memory: 3440kb

input:

320

output:

5B9[8B9[3B]]4[DF]9[8[DF]9[3[DF]]]D4B9[8B9[3B]]D6[6D9[8D9[D]]5[FB]9[8[FB]9[[FB]]]F]9[8[6D9[8D9[D]]5[FB]9[8[FB]9[[FB]]]F]9[[6D9[8D9[D]]5[FB]9[8[FB]9[[FB]]]F]]]6B9[8B9[B]]3[FD]9[8[FD]9[3[FD]]]2[6B9[8B9[B]]D7[7D9[8D]6[FB]9[8[FB]]F]9[8[7D9[8D]6[FB]9[8[FB]]F]]7B9[8B]5[FD]9[8[FD]9[[FD]]]2[7B9[8B]D3[3D9[4D]...

result:

wrong answer invalid output

Subtask #3:

score: 0
Wrong Answer

Test #28:

score: 0
Wrong Answer
time: 0ms
memory: 3368kb

input:

1000000

output:

B9[6B9[6B9[3B9[8B9[7B9[B]]]]]]9[6[DF]9[6[DF]9[3[DF]9[8[DF]9[7[DF]9[[DF]]]]]]]D9[6B9[6B9[3B9[8B9[7B9[B]]]]]]D4[4D9[7D9[7D9[D9[4D9[8D]]]]]3[FB]9[7[FB]9[7[FB]9[[FB]9[4[FB]9[8[FB]]]]]]F]9[7[4D9[7D9[7D9[D9[4D9[8D]]]]]3[FB]9[7[FB]9[7[FB]9[[FB]9[4[FB]9[8[FB]]]]]]F]9[7[4D9[7D9[7D9[D9[4D9[8D]]]]]3[FB]9[7[FB]...

result:

wrong answer invalid output

Subtask #4:

score: 0
Wrong Answer

Test #37:

score: 0
Wrong Answer
time: 0ms
memory: 3308kb

input:

999999

output:

9[6B9[6B9[3B9[8B9[7B9[B]]]]]]D4[4D9[7D9[7D9[D9[4D9[8D]]]]]3[FB]9[7[FB]9[7[FB]9[[FB]9[4[FB]9[8[FB]]]]]]F]9[7[4D9[7D9[7D9[D9[4D9[8D]]]]]3[FB]9[7[FB]9[7[FB]9[[FB]9[4[FB]9[8[FB]]]]]]F]9[7[4D9[7D9[7D9[D9[4D9[8D]]]]]3[FB]9[7[FB]9[7[FB]9[[FB]9[4[FB]9[8[FB]]]]]]F]9[[4D9[7D9[7D9[D9[4D9[8D]]]]]3[FB]9[7[FB]9[7...

result:

wrong answer invalid output

Subtask #5:

score: 0
Wrong Answer

Test #46:

score: 0
Wrong Answer
time: 2ms
memory: 3400kb

input:

10000000000

output:

B9[B9[B9[8B9[7B9[6B9[6B9[2B9[7B9[7B9[2B]]]]]]]]]]9[[DF]9[[DF]9[8[DF]9[7[DF]9[6[DF]9[6[DF]9[2[DF]9[7[DF]9[7[DF]9[2[DF]]]]]]]]]]]D9[B9[B9[8B9[7B9[6B9[6B9[2B9[7B9[7B9[2B]]]]]]]]]]D4[4D9[9[5D9[8D9[3D9[3D9[3D9[D9[8D9[3D9[D]]]]]]]]]]3[FB]9[9[5[FB]9[8[FB]9[3[FB]9[3[FB]9[3[FB]9[[FB]9[8[FB]9[3[FB]9[[FB]]]]]]...

result:

wrong answer invalid output

Subtask #6:

score: 0
Wrong Answer

Test #55:

score: 0
Wrong Answer
time: 1ms
memory: 3392kb

input:

9999999999

output:

9[B9[B9[8B9[7B9[6B9[6B9[2B9[7B9[7B9[2B]]]]]]]]]]D4[4D9[9[5D9[8D9[3D9[3D9[3D9[D9[8D9[3D9[D]]]]]]]]]]3[FB]9[9[5[FB]9[8[FB]9[3[FB]9[3[FB]9[3[FB]9[[FB]9[8[FB]9[3[FB]9[[FB]]]]]]]]]]]F]9[9[5[4D9[9[5D9[8D9[3D9[3D9[3D9[D9[8D9[3D9[D]]]]]]]]]]3[FB]9[9[5[FB]9[8[FB]9[3[FB]9[3[FB]9[3[FB]9[[FB]9[8[FB]9[3[FB]9[[FB...

result:

wrong answer invalid output

Subtask #7:

score: 0
Wrong Answer

Test #64:

score: 0
Wrong Answer
time: 2ms
memory: 3540kb

input:

100000000000000

output:

B9[5B9[2B9[5B9[7B9[2B9[7B9[2B9[4B9[6B9[5B9[9[3B9[3B9[4B]]]]]]]]]]]]]]9[5[DF]9[2[DF]9[5[DF]9[7[DF]9[2[DF]9[7[DF]9[2[DF]9[4[DF]9[6[DF]9[5[DF]9[9[3[DF]9[3[DF]9[4[DF]]]]]]]]]]]]]]]D9[5B9[2B9[5B9[7B9[2B9[7B9[2B9[4B9[6B9[5B9[9[3B9[3B9[4B]]]]]]]]]]]]]]D4[4D9[2D9[D9[7D9[3D9[D9[8D9[5D9[6D9[7D9[2D9[9[6D9[D9[2...

result:

wrong answer invalid output

Subtask #8:

score: 0
Wrong Answer

Test #84:

score: 0
Wrong Answer
time: 2ms
memory: 3496kb

input:

99999999999999

output:

9[5B9[2B9[5B9[7B9[2B9[7B9[2B9[4B9[6B9[5B9[9[3B9[3B9[4B]]]]]]]]]]]]]]D4[4D9[2D9[D9[7D9[3D9[D9[8D9[5D9[6D9[7D9[2D9[9[6D9[D9[2D]]]]]]]]]]]]]]3[FB]9[2[FB]9[[FB]9[7[FB]9[3[FB]9[[FB]9[8[FB]9[5[FB]9[6[FB]9[7[FB]9[2[FB]9[9[6[FB]9[[FB]9[2[FB]]]]]]]]]]]]]]]F]9[2[4D9[2D9[D9[7D9[3D9[D9[8D9[5D9[6D9[7D9[2D9[9[6D9...

result:

wrong answer invalid output

Subtask #9:

score: 0
Wrong Answer

Test #103:

score: 0
Wrong Answer
time: 3ms
memory: 3444kb

input:

1000000000000000000

output:

B9[9[2B9[5B9[2B9[8B9[6B9[3B9[6B9[9[4B9[B9[7B9[3B9[8B9[5B9[8B9[5B9[6B]]]]]]]]]]]]]]]]]]9[9[2[DF]9[5[DF]9[2[DF]9[8[DF]9[6[DF]9[3[DF]9[6[DF]9[9[4[DF]9[[DF]9[7[DF]9[3[DF]9[8[DF]9[5[DF]9[8[DF]9[5[DF]9[6[DF]]]]]]]]]]]]]]]]]]]D9[9[2B9[5B9[2B9[8B9[6B9[3B9[6B9[9[4B9[B9[7B9[3B9[8B9[5B9[8B9[5B9[6B]]]]]]]]]]]]]...

result:

wrong answer invalid output

Subtask #10:

score: 0
Wrong Answer

Test #128:

score: 0
Wrong Answer
time: 3ms
memory: 3508kb

input:

999999999999999999

output:

9[9[2B9[5B9[2B9[8B9[6B9[3B9[6B9[9[4B9[B9[7B9[3B9[8B9[5B9[8B9[5B9[6B]]]]]]]]]]]]]]]]]]D4[4D9[4D9[5D9[2D9[D9[4D9[3D9[6D9[7D9[4D9[6D9[9[8D9[D9[4D9[7D9[8D9[2D9[3D]]]]]]]]]]]]]]]]]]3[FB]9[4[FB]9[5[FB]9[2[FB]9[[FB]9[4[FB]9[3[FB]9[6[FB]9[7[FB]9[4[FB]9[6[FB]9[9[8[FB]9[[FB]9[4[FB]9[7[FB]9[8[FB]9[2[FB]9[3[FB]...

result:

wrong answer invalid output