| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 359007 | 叶梓皓 | 【C6-7】马的遍历 | C++ | 运行出错 | 0 | 3 MS | 336 KB | 569 | 2025-10-30 21:14:13 |
#include<bits/stdc++.h> using namespace std; int r[20][3]; int dx[5]={0,2,1,-1,-2}; int dy[5]={0,1,2,2,1}; int c; char a[100]; void p(int k){ c++; cout<<c<<":"; for(int i=0;i<k-1;i++){ cout<<r[i][0]<<","<<r[i][1]<<"->"; if(i!=k){ cout<<"->"; } } cout<<'4'<<","<<'8'<<endl; } void dfs(int x,int y,int k){ r[k][1]=x; r[k][2]=y; if(x==4&&y==8){ p(k); } int tx,ty; for(int i=0;i<=3;i++){ tx=x+dx[i]; ty=y+dy[i]; if(tx>=1&&tx<=4&&ty>=1&&ty<=8){ dfs(tx,ty,k+1); } } } int main(){ dfs(1,1,2); return 0; }