#include <bits/stdc++.h>
using namespace std;
int ma[30000][30000], x, y, n;
void dfs (int i, int j, int now, int way){
if (now != n * n + 1){
ma[i][j] = now;
if (way == 1){
if (ma[i][j + 1])dfs (i + 1, j, now + 1, 2);
else dfs (i, j + 1, now + 1, 1);
}
if (way == 2){
if (ma[i + 1][j])dfs (i, j - 1, now + 1, 3);
else dfs (i + 1, j, now + 1, 2);
}
if (way == 3){
if (ma[i][j - 1])dfs (i - 1, j, now + 1, 4);
else dfs (i, j - 1, now + 1, 3);
}
if (way == 4){
if (ma[i - 1][j])dfs (i, j + 1, now + 1, 1);
else dfs (i - 1, j, now + 1, 4);
}
}
}
int main (){
cin >> n >> x >> y;
ma[0][0] = 1;
dfs (0, 1, 2, 1);
cout << ma[x][y];
return 0;
}
终端显示:
No valid executable file was produced by the compiler
/usr/bin/ld: ./ccRrh7zr.o: in function `dfs(int, int, int, int)':
src:(.text+0x16): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in ./ccRrh7zr.o
/usr/bin/ld: src:(.text+0x1c): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in ./ccRrh7zr.o
/usr/bin/ld: ./ccRrh7zr.o: in function `main':
src:(.text+0x213): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in ./ccRrh7zr.o
/usr/bin/ld: src:(.text+0x226): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in ./ccRrh7zr.o
/usr/bin/ld: src:(.text+0x235): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in ./ccRrh7zr.o
/usr/bin/ld: src:(.text+0x266): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in ./ccRrh7zr.o
/usr/bin/ld: src:(.text+0x26c): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in ./ccRrh7zr.o
/usr/bin/ld: ./ccRrh7zr.o: in function `__static_initialization_and_destruction_0(int, int)':
src:(.text+0x2c6): relocation truncated to fit: R_X86_64_PC32 against `.bss'
/usr/bin/ld: src:(.text+0x2d9): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: 错误:ld 返回 1