Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
180457 A班邓淑文 骑士遍历1 C++ 运行超时 3 1000 MS 264 KB 510 2024-08-21 13:43:51

Tests(2/55):


#include <bits/stdc++.h> using namespace std; const int maxn=6+10; int dx[]={1,2,2,1}; int dy[]={-2,-1,1,2}; int a[10005]; int n,m,cnt; bool f=false; void dfs(int x,int y,int st){ if(f)return ; if(x<1 || x>n || y<1 || y>m)return ; if(x==n && y==m){ for(int i=1;i<st;i++)cout<<a[i]<<" "; f=true; return ; } for(int i=0;i<4;i++){ int nx=x+dx[i],ny=y+dy[i]; a[st]=i+1; dfs(nx,ny,st+1); a[st]=0; } } int main(){ cin>>n>>m; dfs(1,1,1); if(!f)cout<<-1; return 0; }


测评信息: