洛谷IDE:编译失败!我该怎么解决?
  • 板块学术版
  • 楼主YingHN
  • 当前回复7
  • 已保存回复7
  • 发布时间2022/10/24 16:51
  • 上次更新2023/10/27 06:08:44
查看原帖
洛谷IDE:编译失败!我该怎么解决?
494896
YingHN楼主2022/10/24 16:51

这是我的代码:

#include<bits/stdc++.h>
using namespace std;


/* --------------- fast io --------------- */ // begin
namespace Fread {
	const int SIZE = 1 << 21;
	char buf[SIZE], *S, *T;
	inline char getchar() {
		if (S == T) {
			T = (S = buf) + fread(buf, 1, SIZE, stdin);
			if (S == T) return '\n';
		}
		return *S++;
	}
} // namespace Fread
namespace Fwrite {
	const int SIZE = 1 << 21;
	char buf[SIZE], *S = buf, *T = buf + SIZE;
	inline void flush() {
		fwrite(buf, 1, S - buf, stdout);
		S = buf;
	}
	inline void putchar(char c) {
		*S++ = c;
		if (S == T) flush();
	}
	struct NTR {
		~ NTR() {
			flush();
		}
	} ztr;
} // namespace Fwrite
#ifdef ONLINE_JUDGE
#define getchar Fread :: getchar
#define putchar Fwrite :: putchar
#endif
namespace Fastio {
	struct Reader {
		template<typename T>
		Reader& operator >> (T& x) {
			char c = getchar();
			T f = 1;
			while (c < '0' || c > '9') {
				if (c == '-') f = -1;
				c = getchar();
			}
			x = 0;
			while (c >= '0' && c <= '9') {
				x = x * 10 + (c - '0');
				c = getchar();
			}
			x *= f;
			return *this;
		}
		Reader& operator >> (char& c) {
			c = getchar();
			while (c == ' ' || c == '\n') c = getchar();
			return *this;
		}
		Reader& operator >> (char* str) {
			int len = 0;
			char c = getchar();
			while (c == ' ' || c == '\n') c = getchar();
			while (c != ' ' && c != '\n' && c != '\r') { // \r\n in windows
				str[len++] = c;
				c = getchar();
			}
			str[len] = '\0';
			return *this;
		}
		Reader() {}
	} cin;
	const char endl = '\n';
	struct Writer {
		template<typename T>
		Writer& operator << (T x) {
			if (x == 0) {
				putchar('0');
				return *this;
			}
			if (x < 0) {
				putchar('-');
				x = -x;
			}
			static int sta[45];
			int top = 0;
			while (x) {
				sta[++top] = x % 10;
				x /= 10;
			}
			while (top) {
				putchar(sta[top] + '0');
				--top;
			}
			return *this;
		}
		Writer& operator << (char c) {
			putchar(c);
			return *this;
		}
		Writer& operator << (char* str) {
			int cur = 0;
			while (str[cur]) putchar(str[cur++]);
			return *this;
		}
		Writer& operator << (const char* str) {
			int cur = 0;
			while (str[cur]) putchar(str[cur++]);
			return *this;
		}
		Writer() {}
	} cout;
} // namespace Fastio
#define cin Fastio :: cin
#define cout Fastio :: cout
#define endl Fastio :: endl
/* --------------- fast io --------------- */ // end


const int INF = 1e9 + 1, MAXN = 1e9 + 1;
int nox, noy, x, y;
int f[MAXN][MAXN];
struct POINT {
	int x;
	int y;
	int step;

	struct POINT operator +(const struct POINT X) const {
		return {X.x+x, X.y+y, X.step+step};
	}
} DRC[8] = {
	POINT{0, 1, 1},
	//{0, -1, 1},
	POINT{0, 0, 0},
	POINT{1, 1, 1},
	POINT{1, -1, 1},
	POINT{1, 0, 1},
	POINT{-1, 1, 1},
	//{-1, -1, 1},
	POINT{0, 0, 0},
	//{-1, 0, 1}
	POINT{0, 0, 0}
};
POINT add(POINT a, POINT b) {
	return POINT {a.x+b.x, a.y+b.y, a.step+b.step};
}
bool check(struct POINT p) {
	if(p.x > x || p.y > y || p.x < 0 || p.y < 0)return false;
	else return true;
}
int bfs() {
	queue<struct POINT> que;
	que.push(POINT {0, 0, 0});
	while(!que.empty()) {
		for(int i = 0; i < 8; ++i) {
			struct POINT next = add(que.front(), DRC[i]);
			if(f[next.x][next.y] > next.step && check(next)) {
				que.push(next);
				f[next.x][next.y] = next.step;
			}
		}
		que.pop();
	}
	return f[x][y];
}
void DFS(POINT p) {
	if(p.x == x && p.y == y) {
		f[x][y] = max(f[x][y], p.step);
		return;
	}
	for(int i = 0; i < 8; ++i) {
		struct POINT next = add(p, DRC[i]);
		if(f[next.x][next.y] > next.step && check(next)) {
			f[next.x][next.y] = next.step;
			DFS(next);
		}
	}
	return;
}
int dfs() {
	DFS(POINT {0, 0, 0});
	return f[x][y];
}
int main() {
	for(int i = 0; i <= 5*1e5; ++i) {
		srand(i);
		nox = (int)rand() % (int)(2 * 1e9 + 1) - 1e9;
		noy = (int)rand() % (int)(2 * 1e9 + 1) - 1e9;
		x = (int)rand() % (int)(2 * 1e9 + 1) - 1e9;
		y = (int)rand() % (int)(2 * 1e9 + 1) - 1e9;
		if(x < 0) nox = -nox, x = -x;
		if(y < 0) noy = -noy, y = -y;
		for(int i = 0; i < 8; ++i)
			if(DRC[i].x == nox && DRC[i].y == noy)
				DRC[i] = POINT {0, 0, 0};
		for(int i = 0; i <= x; ++i) { //memset f = INF
			for(int j = 0; j <= y; ++j) {
				f[i][j] = INF;
			}
		}
		int B = bfs();
		for(int i = 0; i <= x; ++i) { //memset f = INF
			for(int j = 0; j <= y; ++j) {
				f[i][j] = INF;
			}
		}
		int D = dfs();
		if(B != D)cout<<"ERR!";
		else cout<<"i = "<<i<<endl;
	}

}

当我运行在洛谷IDE时,报错:

No valid executable file was produced by the compiler
./ccRGALkK.o: in function `__static_initialization_and_destruction_0(int, int)':
src:(.text+0x82f): relocation truncated to fit: R_X86_64_PC32 against `.bss'
src:(.text+0x842): relocation truncated to fit: R_X86_64_PC32 against `.bss'
/nix/store/js66s0xwjnzg0ggi2lq9bcvlk6x2za13-binutils-2.35.2/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: 错误:ld 返回 1

各位大佬帮忙看看

2022/10/24 16:51
加载中...