早上好
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long
const int INF=0x3f3f3f3f;
const int Maxn=1010;
struct node
{
int x,y;
vector <int> ans;
};
bool vis[Maxn][Maxn];
int a,b,n;
void bfs(int x,int y)
{
queue <node> q;
node qwq;
qwq.x=x; qwq.y=y;
q.push(qwq);
while(1)
{
node top;top=q.front();
q.pop();
if(top.y==n)
{
cout<<top.ans.size();
for(int i=0;i<top.ans.size();i++)
{
cout<<' '<<top.ans[i];
}
cout<<endl;
break;
}
if(top.x<a)
{
node top2=top;
top2.x=a;
top2.ans.push_back(1);
if(!vis[top2.x][top2.y])
{
q.push(top2);
vis[top2.x][top2.y]=1;
}
}
if(top.y<b)
{
node top2=top;
top2.y=b;
top2.ans.push_back(2);
if(!vis[top2.x][top2.y])
{
q.push(top2);
vis[top2.x][top2.y]=1;
}
}
if(top.x>0)
{
node top2=top;
top2.x=0;
top2.ans.push_back(3);
if(!vis[top2.x][top2.y])
{
q.push(top2);
vis[top2.x][top2.y]=1;
}
}
if(top.y>0)
{
node top2=top;
top2.y=0;
top2.ans.push_back(4);
if(!vis[top2.x][top2.y])
{
q.push(top2);
vis[top2.x][top2.y]=1;
}
}
if(top.y>0&&top.x<a)
{
node top2=top;
top2.y-=min(a-top2.x,top2.y);
top2.x+=min(a-top2.x,top2.y);
top2.ans.push_back(5);
if(!vis[top2.x][top2.y])
{
q.push(top2);
vis[top2.x][top2.y]=1;
}
}
if(top.x>0&&top.y<b)
{
node top2=top;
top2.y+=min(b-top2.y,top2.x);
top2.x-=min(b-top2.y,top2.x);
top2.ans.push_back(6);
if(!vis[top2.x][top2.y])
{
q.push(top2);
vis[top2.x][top2.y]=1;
}
}
}
}
int main()
{
int T;cin>>T;
while(T--)
{
cin>>a>>b>>n;
//init
bfs(0,0);
//dfs
memset(vis,false,sizeof(vis));
}
return 0;
}
/*
in1:
2
3 5 4
5 7 3
out1:
6 2 5 3 5 2 5
6 1 6 1 6 4 6
*/