rt,此代码在测试样例时一直死循环输出2 3
#include<iostream>
using namespace std;
struct type{
int x,y;
}a[1010][1010];
int main(){
int n,m,sx,sy,nx,ny;
cin>>m>>n>>sx>>sy;
cout<<sx<<" "<<sy<<endl;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>a[i][j].x>>a[i][j].y;
while(true)
{
if(a[sx][sy].x==0&&a[sx][sy].y==0) break;
cout<<a[sx][sy].x<<" "<<a[sx][sy].y<<endl;
sx=a[sx][sy].x,sy=a[sx][sy].y;
}
return 0;
}