关于 luogu C++ 环境问题
  • 板块学术版
  • 楼主MrPython小河狸贝瓦
  • 当前回复11
  • 已保存回复14
  • 发布时间2024/1/7 17:59
  • 上次更新2024/1/7 20:43:48
查看原帖
关于 luogu C++ 环境问题
679581
MrPython小河狸贝瓦楼主2024/1/7 17:59
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
struct {
    int a=INT_MAX,b=INT_MIN;
} c[N];
int main(){
	c[0].a=1;
	return 0;
}

如上代码,在 luogu C++14(GCC 9) 上无法编译,但是本地及其他 oj 均可行。 luogu 编译输出:

Nothing is compiled: OUTPUT exceeds.

本地测试: 环境 Ubuntu 23.04

╭─     /tmp                                                         17:51:41
╰─❯ cat tmp.cpp 
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
struct node{
	int maxn=INT_MIN,
    minn=INT_MAX;
}c[N];

int main(){
	
	return 0;
}


╭─     /tmp                                                         17:51:43
╰─❯ time g++-9 tmp.cpp -o tmp  -DONLINE_JUDGE -Wall -fno-asm -lm -march=native
g++-9 tmp.cpp -o tmp -DONLINE_JUDGE -Wall -fno-asm -lm -march=native  1.56s user 0.19s system 99% cpu 1.764 total

╭─     /tmp                                                         17:51:46
╰─❯ du -h tmp                                                                 
7.7M	tmp

另外,这份代码还在 一个 nix docker 按照 https://github.com/luogu-dev/judge-env 生成的 g++ 中测试过,环境应与 luogu 评测环境相同。他一样可以通过编译。

  • 是由于初始化导致生成的可执行文件过大 不是。
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
struct {
    int a=INT_MAX,b=INT_MIN;
} c[N];

int main(){
	c[0].a=1;
	return 0;
}

这份代码在本地测得大小为 7.7MB,与有问题的代码占用相同。而他可以正常编译运行。另外,可执行文件过大导致的错误,报错信息应该为:

g++: 编译器内部错误:File size limit exceeded signal terminated program as
请提交一份完整的错误报告,
如有可能请附上经预处理后的源文件。
参阅 <https://gcc.gnu.org/bugs/> 以获取指示。
  • 编译超时导致的 本地测得上述代码编译时间为 1.764s。即使在不同平台有所出入,也不应该差距如此之大。

那么还能是什么原因导致的如此返回结果?求懂哥或开发组解答。

2024/1/7 17:59
加载中...