WangBX @ 2026-07-25 14:03:55
洛谷使用的 testlib.h 为 0.9.41 版本,其中的 vtos() 函数含有一个 BUG,其每次调用返回的结果都指向同一块内存。
因此,建议不要使用 testlib.h 自带 vtos,自己手写一个,或(其实大部分情况下)直接使用 %lld 输出。
故,如果在 quitf 中连续调用两次 vtos().c_str(),例如 quitf(_wa,"Expected %s, Read %s,vtos(1).c_str(),vtos(2).c_str());,那么实际上会输出 Expected 2, Read 2。
相关测试见 https://www.luogu.com.cn/record/288475267,其 SPJ 源码如下:
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char * argv[]) {
registerTestlibCmd(argc, argv);
const char* s=vtos(4).c_str();
const char* t=vtos(0).c_str();
quitf(_wa, "version=%s, s=%p, t=%p, 4='%s', 0='%s'", VERSION, s, t, vtos(4).c_str(), vtos(0).c_str());
}
by MCbucket @ 2026-07-25 14:04:44
qp
by ouyang_mingde_Luke @ 2026-07-25 14:06:34
qp!!!✌
by man_7891 @ 2026-07-25 14:06:44
qp(?
by lg12321a @ 2026-07-25 14:07:15
pq
by FrankShix @ 2026-07-25 14:08:46
qp
by sonny2011 @ 2026-07-25 14:09:09
qp
by fl0ppy_ @ 2026-07-25 14:10:18
qp?
by YHW12345 @ 2026-07-25 14:10:21
qp
by TangLingxin @ 2026-07-25 14:13:01
qp第10条回复
by crh1215 @ 2026-07-25 14:13:22
qp!