QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#615706#9439. Aim Highucup-team3510#AC ✓1ms3792kbC++141.3kb2024-10-05 19:50:232024-10-05 19:50:24

Judging History

This is the latest submission verdict.

  • [2024-10-05 19:50:24]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 3792kb
  • [2024-10-05 19:50:23]
  • Submitted

answer

#include<iostream>
#include<cstring>
using namespace std;
int T,n,a[110][210],num,ans[100000][6];
inline void print(int x,int y,int z)
{
	num++;
	ans[num][1]=ans[num][3]=x-100-1;
	ans[num][5]=x-100,ans[num][0]=y+z-100;
	ans[num][2]=ans[num][4]=y-100;
}
bool dfs(int now)
{
	if(!now)
	{
		for(int i=0;i<=200;i++)
		{
			if(a[now][i])
			{
				return 0;
			}
		}
		return 1;
	}
	for(int i=0;i<=200;i++)
	{
		a[now][i]-=(now<=100);
		a[now][i]=max(0,a[now][i]);
		a[now-1][i]=a[now][i];
	}
	if(a[now][0]||a[now][200])
	{
		return 0;
	}
	for(int i=0,last;i<=200;i++)
	{
		if(!a[now][i])
		{
			last=i;
			continue;
		}
		int j=i;
		while(a[now][j])
		{
			j++;
		}
		if(i<=(last+j>>1))
		{
			a[now-1][i-1]+=a[now][i];
			while(a[now][i]--)
			{
				print(now,i,-1);
			}
		}
		else
		{
			a[now-1][i+1]+=a[now][i];
			while(a[now][i]--)
			{
				print(now,i,1);
			}
		}
	}
	return dfs(now-1);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>T;
	while(T--)
	{
		cin>>n;
		if(n>=5)
		{
			cout<<-1<<endl;
			continue;
		}
		memset(a,0,sizeof(a)),num=0;
		a[n+100][100]=1,dfs(n+100);
		cout<<num<<endl;
		for(int i=num;i;i--)
		{
			for(int j=0;j<6;j++)
			{
				cout<<ans[i][j]<<" ";
			}
			cout<<endl;
		}
	}
	return 0;
}

詳細信息

Test #1:

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

input:

1
1

output:

1
-1 0 0 0 0 1 

result:

ok Output is valid. OK

Test #2:

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

input:

6
1
2
3
4
5
6

output:

1
-1 0 0 0 0 1 
3
1 0 0 0 0 1 
-2 0 -1 0 -1 1 
-1 1 0 1 0 2 
9
0 -1 1 -1 1 0 
-3 -1 -2 -1 -2 0 
2 0 1 0 1 1 
1 0 0 0 0 1 
-2 0 -1 0 -1 1 
-3 0 -2 0 -2 1 
1 1 0 1 0 2 
-2 1 -1 1 -1 2 
-1 2 0 2 0 3 
39
0 -4 1 -4 1 -3 
-5 -4 -4 -4 -4 -3 
4 -3 3 -3 3 -2 
1 -3 2 -3 2 -2 
0 -3 1 -3 1 -2 
-1 -3 -2 -3 -2 -2...

result:

ok Output is valid. OK

Extra Test:

score: 0
Extra Test Passed