QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#366808#7115. Can You Guess My Sequence?crsfaa#AC ✓3ms3832kbC++14965b2024-03-25 08:57:462024-03-25 08:57:46

Judging History

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

  • [2024-03-25 08:57:46]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3832kb
  • [2024-03-25 08:57:46]
  • 提交

answer

#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
#define int long long
using Yukinoshita Yukino;
int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') w=ch=='-'?-1:1,ch=getchar();
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
int a[30],res[30];
int n,cnt,x;
bool check(int m)
{
	if(n!=m) return 0;
	int i;
	for(i=1;i<=n;i++)
		if(a[i]!=res[i])
			return 0;
	return 1;
}
void dfs(int d,int pre)
{
	cnt++;
	if(check(d-1))
	{
		cout<<cnt;
		exit(0);
	}
	for(pre++;pre<20;pre++)
		a[d]=pre,dfs(d+1,pre);
}
void dfs2(int d,int pre)
{
	cnt++;
	if(cnt==x)
	{
		cout<<d-1<<endl;
		for(int i=1;i<d;i++)
			cout<<a[i]<<' ';
		exit(0);
	}
	for(pre++;pre<20;pre++)
		a[d]=pre,dfs2(d+1,pre);
}
signed main()
{
	string t;
	cin>>t;
	if(t=="Alice")
	{
		n=read();
		for(int i=1;i<=n;i++)
			res[i]=read();
		dfs(1,-1);
		return 0;
	}
	cin>>x;
	dfs2(1,-1);
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 3832kb

First Run Input

Alice
6
2 3 5 8 10 15

First Run Output

832999

Second Run Input

Bob
832999

Second Run Output

6
2 3 5 8 10 15 

result:

ok correct

Test #2:

score: 100
Accepted
time: 0ms
memory: 3624kb

First Run Input

Alice
20
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

First Run Output

21

Second Run Input

Bob
21

Second Run Output

20
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 

result:

ok correct

Test #3:

score: 100
Accepted
time: 0ms
memory: 3656kb

First Run Input

Alice
1
0

First Run Output

2

Second Run Input

Bob
2

Second Run Output

1
0 

result:

ok correct

Test #4:

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

First Run Input

Alice
2
0 15

First Run Output

524259

Second Run Input

Bob
524259

Second Run Output

2
0 15 

result:

ok correct

Test #5:

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

First Run Input

Alice
10
1 3 5 7 9 11 12 14 15 16

First Run Output

698955

Second Run Input

Bob
698955

Second Run Output

10
1 3 5 7 9 11 12 14 15 16 

result:

ok correct

Test #6:

score: 100
Accepted
time: 3ms
memory: 3620kb

First Run Input

Alice
3
16 17 18

First Run Output

1048564

Second Run Input

Bob
1048564

Second Run Output

3
16 17 18 

result:

ok correct

Test #7:

score: 100
Accepted
time: 0ms
memory: 3620kb

First Run Input

Alice
18
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 19

First Run Output

25

Second Run Input

Bob
25

Second Run Output

18
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 19 

result:

ok correct