一道蒟蒻题 感觉思路上没问题却是死循环
查看原帖
一道蒟蒻题 感觉思路上没问题却是死循环
813591
ZYZ1021楼主2023/8/4 23:58
#include <bits/stdc++.h>
using namespace std;
struct Point{
	int x; int y;
}task[1002][1002];
int main(){
	int m, n, nowx, nowy, i, j; scanf("%d %d %d %d", &m, &n, &nowx, &nowy);
	for(i = 1;i <= m;i ++) for(j = 1;j <= n;j ++) scanf("%d %d", &task[i][j].x, &task[i][j].y);
	while(nowx != 0 && nowy != 0){
		printf("%d %d\n", nowx, nowy);if(nowx == 2 && nowy == 3) break;
		nowx = task[nowx][nowy].x; nowy = task[nowx][nowy].y;
		
	}
	return 0;
}

2023/8/4 23:58
加载中...