QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#59983#1845. PermuteExplodingKonjacML 204ms3668kbC++175.6kb2022-11-02 11:32:312022-11-02 11:32:34

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-02 11:32:34]
  • Judged
  • Verdict: ML
  • Time: 204ms
  • Memory: 3668kb
  • [2022-11-02 11:32:31]
  • Submitted

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
		~FastOutput(){ flush(); }
#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; }
#else
		FastInput(FILE *f=stdin): FastIOBase(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;
}
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

int T,cnt[10],cnt2[10],old[10],my[10];
struct Data
{
	int x,c;
	Data()=default;
	Data(int _x,int _c): x(_x),c(_c){}
	inline bool operator <(const Data &rhs)const
		{ return c>rhs.c; }
};

constexpr int pw10[6]={1,3,2,6,4,5},sp10[6]={0,1,4,6,5,2};
inline void solve(vector<int> v1,vector<Data> v2)
{
	auto cmp=[](int x,int y){ return x%7<y%7; };
	sort(v1.begin(),v1.end(),cmp);
	int tmp=pw10[v1.size()%6],x=0;
	for(auto &i: v2) x=(x+tmp*i.x*sp10[i.c%6])%7,tmp=tmp*pw10[i.c%6]%7;
	do
	{
		int y=x;
		for(int i=0;i<v1.size();i++) y=(y+pw10[i%6]*v1[i])%7;
		if(!y)
		{
			reverse(v1.begin(),v1.end());
			reverse(v2.begin(),v2.end());
			qout.writeln(v1.size()+v2.size());
			for(auto &i: v2) qout<<i.c<<' '<<i.x<<'\n',my[i.x]+=i.c;
			for(auto &i: v1) qout<<1<<' '<<i<<'\n',my[i]++;
			return;
		}
	}while(next_permutation(v1.begin(),v1.end(),cmp));
	for(int i=0;i<10;i++) my[i]=old[i];
	qout.writeln(-1);
}
inline void process(const vector<int> &tg)
{
	vector<int> v1;
	vector<Data> v2;
	for(auto &i: tg)
		for(int j=0;j<10;j++)
		{
			if(j%7!=i || !cnt[j]) continue;
			cnt[j]--,v1.push_back(j);
			break;
		}
	for(int i=0;i<10;i++)
		if(cnt[i]) v2.emplace_back(i,cnt[i]);
	solve(v1,v2);
}
int main()
{
	qin>>T;
	while(T--)
	{
		vector<Data> vec;
		for(int i=0;i<10;i++) cnt2[i]=0;
		for(int i=0;i<10;i++) qin>>cnt[i],cnt2[i%7]+=cnt[i];
		for(int i=0;i<10;i++) if(cnt2[i]) vec.emplace_back(i,cnt2[i]);
		sort(vec.begin(),vec.end());
		if(vec.size()>=4)
			process({vec[0].x,vec[1].x,vec[2].x,vec[3].x});
		else if(vec.size()>=3 && vec[0].c>=2 && vec[1].c>=2)
			process({vec[0].x,vec[0].x,vec[1].x,vec[1].x,vec[2].x});
		else if(vec.size()>=3 && vec[0].c>=5)
			process({vec[0].x,vec[0].x,vec[0].x,vec[0].x,vec[0].x,vec[1].x,vec[2].x});
		else if(vec.size()>=2 && vec[0].c>=3 && vec[1].c>=2)
			process({vec[0].x,vec[0].x,vec[0].x,vec[1].x,vec[1].x});
		else if(vec.size()==1)
		{
			vector<Data> tmp;
			for(int i=0;i<10;i++)
				if(cnt[i]) tmp.emplace_back(i,cnt[i]);
			solve({},tmp);
		}
		else
		{
			vector<int> tmp;
			for(int i=0;i<10;i++)
				for(int j=0;j<cnt[i];j++)
					tmp.push_back(i);
			solve(tmp,{});
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3516kb

input:

3
0 1 0 0 1 0 0 0 0 0
0 2 0 0 0 0 1 0 0 1
0 1000000000 0 0 0 0 0 0 0 0

output:

2
1 1
1 4
4
1 9
1 6
1 1
1 1
-1

result:

ok T=3

Test #2:

score: 0
Accepted
time: 62ms
memory: 3560kb

input:

100000
0 0 0 1 0 1 1 1 0 1
1 1 0 0 1 0 1 0 1 0
1 1 1 1 0 0 0 1 0 1
0 1 1 0 0 1 1 1 1 0
0 0 1 0 1 0 1 0 1 0
0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 1 1
1 0 1 1 1 0 1 0 0 0
0 1 1 0 0 1 0 1 0 1
1 0 0 1 1 0 0 1 0 0
1 1 0 1 0 0 1 0 1 1
0 0 1 0 0 0 0 1 0 0
0 1 1 1 1 1 1 1 0 1
1 0 0 0 0 1 0 0 0 1
0 0 0 0 1 0 1...

output:

5
1 6
1 9
1 5
1 7
1 3
5
1 8
1 6
1 4
1 0
1 1
6
1 9
1 7
1 3
1 2
1 1
1 0
6
1 8
1 6
1 7
1 2
1 5
1 1
4
1 6
1 4
1 8
1 2
-1
4
1 1
1 8
1 9
1 0
5
1 6
1 3
1 4
1 2
1 0
5
1 9
1 7
1 2
1 5
1 1
-1
6
1 8
1 6
1 0
1 3
1 9
1 1
-1
8
1 9
1 6
1 5
1 4
1 1
1 7
1 3
1 2
-1
4
1 6
1 4
1 8
1 9
7
1 9
1 7
1 6
1 5
1 2
1 8
1 0
6
1 ...

result:

ok T=100000

Test #3:

score: 0
Accepted
time: 87ms
memory: 3668kb

input:

100000
2 1 2 1 0 1 1 0 2 0
1 2 0 1 1 2 1 1 2 1
2 2 2 1 0 2 1 1 2 2
1 1 0 2 0 2 0 1 2 0
1 0 2 2 1 2 1 0 2 2
0 1 2 2 2 1 0 2 1 2
1 1 2 0 0 1 1 0 1 0
1 0 2 2 2 0 1 0 1 1
2 1 1 2 1 0 2 0 0 1
1 0 2 2 2 0 2 1 0 1
2 0 1 1 1 1 1 1 2 1
0 1 1 0 2 0 2 0 1 2
2 1 1 0 2 0 2 1 0 1
1 2 2 2 0 2 1 1 1 0
2 0 0 2 0 2 2...

output:

9
2 8
1 6
1 5
1 2
1 0
1 2
1 0
1 3
1 1
11
2 8
1 7
1 6
1 5
1 4
1 3
1 1
1 9
1 5
1 1
1 0
13
2 9
2 8
1 7
1 6
1 5
1 3
1 2
1 1
1 0
1 0
1 2
1 5
1 1
8
2 8
1 7
1 5
1 3
1 3
1 1
1 5
1 0
12
2 9
1 8
1 6
1 5
1 4
1 3
1 2
1 0
1 2
1 5
1 3
1 8
11
2 9
1 8
1 7
1 5
2 4
1 3
1 2
1 3
1 1
1 2
1 7
7
1 8
1 6
1 2
1 5
1 1
1 2
1 ...

result:

ok T=100000

Test #4:

score: 0
Accepted
time: 108ms
memory: 3564kb

input:

100000
1 3 3 2 3 0 2 1 3 2
3 1 2 0 0 3 1 0 0 1
3 2 0 2 0 2 0 1 3 1
0 1 0 3 1 1 0 3 0 2
2 2 2 3 3 3 1 0 3 0
0 3 0 2 0 3 2 0 2 3
3 0 1 1 3 3 2 1 3 1
1 2 3 0 1 2 2 0 2 3
3 1 0 3 2 0 2 3 1 0
2 1 2 3 0 2 2 3 1 2
3 3 0 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
3 9
...

result:

ok T=100000

Test #6:

score: 0
Accepted
time: 113ms
memory: 3488kb

input:

100000
0 2 1 4 1 4 1 1 3 4
2 3 3 1 3 4 2 1 1 1
1 2 1 3 3 1 1 5 0 0
1 4 0 3 1 1 0 0 0 4
4 3 5 0 0 0 4 2 5 1
3 2 5 1 2 5 0 0 0 1
2 0 5 3 1 3 0 5 1 3
0 2 5 4 5 5 1 1 1 0
1 3 1 4 4 5 2 2 2 1
2 1 2 1 0 0 1 2 5 1
0 2 0 4 5 4 5 2 0 3
5 3 5 5 2 2 4 0 5 5
3 4 2 2 5 1 5 0 3 4
0 3 3 0 5 3 3 4 3 5
0 3 5 4 3 3 4...

output:

12
4 9
3 8
1 7
1 6
3 5
1 4
3 3
1 1
1 3
1 5
1 2
1 1
14
1 9
1 8
1 7
2 6
3 5
3 4
1 3
2 2
2 1
1 0
1 0
1 2
1 5
1 1
11
5 7
1 6
1 5
2 4
2 3
1 2
1 1
1 3
1 1
1 4
1 0
9
3 9
1 5
1 4
2 3
3 1
1 3
1 9
1 1
1 0
11
1 9
5 8
2 7
3 6
4 2
2 1
3 0
1 2
1 1
1 6
1 0
11
1 9
4 5
2 4
1 3
4 2
1 1
2 0
1 0
1 1
1 5
1 2
12
3 9
1 8
...

result:

ok T=100000

Test #7:

score: 0
Accepted
time: 120ms
memory: 3632kb

input:

100000
5 5 0 1 0 3 1 5 3 6
0 5 1 4 2 1 1 5 3 4
1 3 0 5 0 2 4 1 5 5
4 5 4 5 3 5 6 3 1 3
6 0 5 3 3 6 3 5 6 3
6 3 4 4 4 0 0 1 6 3
0 5 2 4 2 4 2 5 3 3
2 4 4 5 1 0 5 6 2 3
3 0 3 5 4 3 3 5 2 6
6 3 6 2 0 5 0 2 2 4
5 3 6 2 2 5 6 4 4 2
0 6 4 3 3 6 0 3 4 4
6 5 1 1 2 6 3 6 5 4
1 3 6 5 0 3 0 1 3 2
6 4 5 2 2 6 1...

output:

12
5 9
3 8
5 7
1 6
2 5
1 3
4 1
4 0
1 0
1 1
1 5
1 9
12
4 9
3 8
4 7
1 6
1 5
2 4
3 3
4 1
1 1
1 7
1 3
1 2
12
4 9
5 8
1 7
3 6
2 5
4 3
2 1
1 0
1 9
1 6
1 3
1 1
14
3 9
1 8
3 7
5 6
5 5
3 4
5 3
3 2
4 1
3 0
1 2
1 6
1 1
1 0
13
3 9
5 8
5 7
3 6
5 5
3 4
3 3
4 2
5 0
1 0
1 2
1 5
1 8
12
3 9
6 8
1 7
4 4
3 3
3 2
2 1
5 ...

result:

ok T=100000

Test #8:

score: 0
Accepted
time: 114ms
memory: 3616kb

input:

100000
0 1 3 6 5 0 5 1 1 4
2 3 7 4 3 2 2 3 7 7
6 4 5 6 7 0 1 7 0 1
1 6 1 2 5 2 5 6 0 2
6 3 0 4 4 5 4 0 4 1
6 4 7 4 3 0 3 5 3 7
0 4 0 0 7 0 3 1 2 4
1 2 6 2 1 0 3 1 2 5
7 3 7 4 1 6 1 3 1 5
7 1 6 4 6 5 2 2 1 5
4 1 7 3 0 3 4 1 3 6
7 5 3 3 1 6 3 5 5 1
2 5 5 7 1 2 5 6 1 6
0 0 7 2 0 0 4 7 1 1
0 5 4 1 7 1 1...

output:

12
4 9
1 8
1 7
4 6
4 4
5 3
2 2
1 1
1 3
1 4
1 6
1 2
14
7 9
7 8
3 7
2 6
2 5
3 4
3 3
6 2
2 1
1 0
1 3
1 2
1 1
1 0
12
1 9
7 7
1 6
6 4
5 3
4 2
4 1
5 0
1 4
1 2
1 0
1 3
12
2 9
6 7
4 6
2 5
4 4
2 3
1 2
5 1
1 6
1 1
1 4
1 0
12
1 9
4 8
4 6
4 5
4 4
3 3
2 1
5 0
1 5
1 3
1 1
1 0
13
7 9
3 8
5 7
3 6
3 4
3 3
6 2
3 1
5 ...

result:

ok T=100000

Test #9:

score: 0
Accepted
time: 130ms
memory: 3612kb

input:

100000
7 3 4 5 2 6 6 3 6 0
8 3 8 6 5 1 8 2 7 7
5 1 8 4 7 0 1 1 1 0
1 1 8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6
1 5
1 9
14
4 9
5 8
3 7
1 6
1 5
2 4
7 3
6 2
6 1
3 0
1 1
1 0
1 3
1 2
11
2 9
5 7
4 5
6 4
5 3
8 2
5 1
1 2
1 3
1 1
1 0
13
7 9
5 8
8 7
8 6
2 5
1 4
1 3
6 ...

result:

ok T=100000

Test #11:

score: 0
Accepted
time: 115ms
memory: 3668kb

input:

100000
0 8 3 9 3 7 10 1 5 1
7 7 2 3 5 7 4 5 2 6
6 1 7 7 6 3 4 5 10 7
7 3 3 8 9 0 1 8 1 5
0 6 1 0 5 2 0 4 7 3
9 7 7 3 1 7 8 10 8 7
4 7 3 7 0 2 2 10 0 10
8 9 5 1 4 7 4 6 4 9
1 1 7 7 8 5 7 5 3 2
3 6 6 8 4 5 5 10 3 10
10 1 7 5 1 5 6 5 9 0
9 1 0 0 0 3 6 1 0 0
5 9 9 8 10 8 1 1 1 4
2 5 10 5 7 3 7 2 4 6
1 8...

output:

13
1 9
5 8
1 7
9 6
6 5
3 4
8 3
3 2
7 1
1 3
1 5
1 6
1 1
14
6 9
2 8
5 7
4 6
6 5
5 4
3 3
1 2
6 1
6 0
1 2
1 5
1 1
1 0
13
7 9
10 8
5 7
4 6
3 5
6 4
6 3
6 2
5 0
1 0
1 3
1 2
1 1
13
5 9
1 8
8 7
1 6
8 4
7 3
2 2
3 1
6 0
1 4
1 2
1 0
1 3
10
3 9
7 8
3 7
2 5
4 4
5 1
1 1
1 4
1 2
1 7
14
7 9
8 8
10 7
7 6
7 5
1 4
3 3
...

result:

ok T=100000

Test #12:

score: 0
Accepted
time: 204ms
memory: 3560kb

input:

100000
494719969 120370150 440274545 51278543 770105708 138663251 867692060 230246532 162623412 131761825
16498099 70750104 350416959 359532393 346253463 539196901 104480711 629723297 27266106 267471731
320561715 423589912 850677494 604957917 815663121 8935553 252297110 812216267 821793396 495865924...

output:

14
131761825 9
162623412 8
230246532 7
867692059 6
138663251 5
770105707 4
51278543 3
440274544 2
120370150 1
494719968 0
1 4
1 2
1 6
1 0
14
267471731 9
27266106 8
629723297 7
104480711 6
539196900 5
346253463 4
359532392 3
350416958 2
70750104 1
16498098 0
1 3
1 5
1 2
1 0
14
495865924 9
821793396 8...

result:

ok T=100000

Test #13:

score: -100
Memory Limit Exceeded

input:

100000
1 0 0 0 0 0 738556701 0 0 0
0 376417170 0 0 0 1 0 0 0 0
0 0 0 169526540 0 1 0 0 0 0
0 0 1 0 0 0 0 0 822697278 0
0 0 0 0 121828077 0 0 0 1 0
0 994528277 0 0 0 0 0 0 0 1
0 0 0 0 0 0 1 0 0 771142048
0 0 0 0 0 77945594 0 0 1 0
1 0 0 0 963629977 0 0 0 0 0
0 0 0 1 0 805871384 0 0 0 0
0 0 0 0 306368...

output:


result: