QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#87939#960. Output Limit ExceededCrysflyAC ✓169ms4112kbC++141.6kb2023-03-14 21:20:352023-03-14 21:20:38

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.
  • [2023-03-14 21:20:38]
  • Judged
  • Verdict: AC
  • Time: 169ms
  • Memory: 4112kb
  • [2023-03-14 21:20:35]
  • Submitted

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 6005
#define inf 0x3f3f3f3f

int n,res[maxn];
vi e[maxn];
int bel[maxn];
bool vis[maxn];
bool dfs(int u){
	if(vis[u])return 0; vis[u]=1;
	for(int v:e[u]){
		int w=bel[v];
		bel[u]=v,bel[v]=u;
		if(!w)return 1;
		bel[w]=0;
		if(dfs(w))return 1;
		bel[u]=0,bel[v]=w,bel[w]=v;
	}return 0;
}
void solve(int m)
{
	res[0]=1;
	For(i,1,m){
		e[i].pb(m+(n-n/i*i)+1);
		For(j,1,i-1) if((n-i+1)%j==0) e[j].pb(m+i);
		memset(vis,0,sizeof vis);
		For(j,1,i)
			if(!bel[j] && dfs(j)) memset(vis,0,sizeof vis);
		bool ok=1;
		For(j,1,i)if(!bel[j]){ok=0;break;}
		res[i]=ok;
	}
}
void brute(){
	solve(n/2);
	cout<<2<<"\n"<<n+1<<' ';
	For(i,0,n)if(i<=n/2)cout<<res[i]<<' ';else cout<<res[n-i]<<" "; exit(0);
}
vi o;
void qwq(int n){
	Rep(i,60,0)
		if(n>>i&1){
			if(!i)o.pb(0);
			else o.pb(i+1);
		}
}
signed main()
{
	n=read();
	if(n<=6005)brute();
	solve(3000);
	cout<<61<<"\n";
	cout<<"2 0 0\n";
	For(i,3,60)cout<<2<<" "<<i-1<<" "<<i-1<<"\n";
	For(i,0,3000)o.pb(res[i]);
	qwq(n-2*3000-1);
	Rep(i,3000,0)o.pb(res[i]);
	cout<<o.size()<<" ";
	for(int x:o)cout<<x<<" ";
	return 0;
}

详细

Test #1:

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

input:

1

output:

2
2 1 1 

result:

ok OK 2 ones: 0 1

Test #2:

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

input:

0

output:

2
1 1 

result:

ok OK 1 ones: 0

Test #3:

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

input:

7

output:

2
8 1 1 1 0 0 1 1 1 

result:

ok OK 6 ones: 0 1 2 5 6 7

Test #4:

score: 0
Accepted
time: 5ms
memory: 3532kb

input:

1000

output:

2
1001 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok OK 18 ones: 0 1 2 3 4 5 6 7 9 991 993 994 995 996 997 998 999 1000

Test #5:

score: 0
Accepted
time: 109ms
memory: 3924kb

input:

1000000000000000000

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 14 ones: 0 1 2 3 4 5 6 999999999999999994 999999999999999995 999999999999999996 999999999999999997 999999999999999998 999999999999999999 1000000000000000000

Test #6:

score: 0
Accepted
time: 109ms
memory: 4096kb

input:

987654321987654321

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 10 ones: 0 1 2 3 4 987654321987654317 987654321987654318 987654321987654319 987654321987654320 987654321987654321

Test #7:

score: 0
Accepted
time: 110ms
memory: 4076kb

input:

268571729873867564

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 8 ones: 0 1 2 3 268571729873867561 268571729873867562 268571729873867563 268571729873867564

Test #8:

score: 0
Accepted
time: 105ms
memory: 3960kb

input:

7900225

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 18 ones: 0 1 2 5 6 19 20 25 26 7900199 7900200 7900205 7900206 7900219 7900220 7900223 7900224 7900225

Test #9:

score: 0
Accepted
time: 106ms
memory: 3928kb

input:

1690950

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 22 ones: 0 1 2 3 4 5 6 7 23 24 25 1690925 1690926 1690927 1690943 1690944 1690945 1690946 1690947 1690948 1690949 1690950

Test #10:

score: 0
Accepted
time: 103ms
memory: 3980kb

input:

3299430

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 20 ones: 0 1 2 3 4 5 6 7 8 27 3299403 3299422 3299423 3299424 3299425 3299426 3299427 3299428 3299429 3299430

Test #11:

score: 0
Accepted
time: 103ms
memory: 4088kb

input:

3755426

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 12 ones: 0 1 2 3 7 27 3755399 3755419 3755423 3755424 3755425 3755426

Test #12:

score: 0
Accepted
time: 104ms
memory: 3852kb

input:

7900224

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 26 ones: 0 1 2 3 4 5 19 20 21 22 23 24 25 7900199 7900200 7900201 7900202 7900203 7900204 7900205 7900219 7900220 7900221 7900222 7900223 7900224

Test #13:

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

input:

582120

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 34 ones: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 23 24 25 582095 582096 582097 582107 582108 582109 582110 582111 582112 582113 582114 582115 582116 582117 582118 582119 582120

Test #14:

score: 0
Accepted
time: 118ms
memory: 4112kb

input:

186145

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 12 ones: 0 1 2 5 6 26 186119 186139 186140 186143 186144 186145

Test #15:

score: 0
Accepted
time: 118ms
memory: 3852kb

input:

5392796

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 20 ones: 0 1 2 3 5 6 7 8 9 25 5392771 5392787 5392788 5392789 5392790 5392791 5392793 5392794 5392795 5392796

Test #16:

score: 0
Accepted
time: 101ms
memory: 3964kb

input:

1690947

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 14 ones: 0 1 2 3 4 5 25 1690922 1690942 1690943 1690944 1690945 1690946 1690947

Test #17:

score: 0
Accepted
time: 110ms
memory: 4044kb

input:

763452298

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 22 ones: 0 1 2 3 4 5 6 7 8 9 29 763452269 763452289 763452290 763452291 763452292 763452293 763452294 763452295 763452296 763452297 763452298

Test #18:

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

input:

701578836

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 26 ones: 0 1 2 3 4 5 6 7 8 9 10 11 29 701578807 701578825 701578826 701578827 701578828 701578829 701578830 701578831 701578832 701578833 701578834 701578835 701578836

Test #19:

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

input:

308897850

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 18 ones: 0 1 2 3 4 5 6 7 27 308897823 308897843 308897844 308897845 308897846 308897847 308897848 308897849 308897850

Test #20:

score: 0
Accepted
time: 111ms
memory: 3980kb

input:

377596828

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 18 ones: 0 1 2 3 4 5 6 23 27 377596801 377596805 377596822 377596823 377596824 377596825 377596826 377596827 377596828

Test #21:

score: 0
Accepted
time: 106ms
memory: 3944kb

input:

524422078

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 42 ones: 0 1 2 3 4 5 6 7 8 9 10 11 16 17 18 19 20 21 23 27 29 524422049 524422051 524422055 524422057 524422058 524422059 524422060 524422061 524422062 524422067 524422068 524422069 524422070 524422071 524422072 524422073 524422074 524422075 524422076 524422077 524422078

Test #22:

score: 0
Accepted
time: 169ms
memory: 3948kb

input:

906130371972379050

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 20 ones: 0 1 2 3 4 5 6 7 8 31 906130371972379019 906130371972379042 906130371972379043 906130371972379044 906130371972379045 906130371972379046 906130371972379047 906130371972379048 906130371972379049 906130371972379050

Test #23:

score: 0
Accepted
time: 110ms
memory: 3964kb

input:

9469980

output:

61
2 0 0
2 2 2
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
2 8 8
2 9 9
2 10 10
2 11 11
2 12 12
2 13 13
2 14 14
2 15 15
2 16 16
2 17 17
2 18 18
2 19 19
2 20 20
2 21 21
2 22 22
2 23 23
2 24 24
2 25 25
2 26 26
2 27 27
2 28 28
2 29 29
2 30 30
2 31 31
2 32 32
2 33 33
2 34 34
2 35 35
2 36 36
2 37 37
2 38 38
2 39 39
2 4...

result:

ok OK 18 ones: 0 1 2 3 4 5 6 7 31 9469949 9469973 9469974 9469975 9469976 9469977 9469978 9469979 9469980