疑惑记录: g++错了?
起因
放假了!来刷点cf A,B,C题轻松轻松.结果
Wrong answer on test 2
△
!
\triangle\!\!\!!
△!
经过
Checker Log
wrong answer 3421st numbers differ - expected: '4999999999', found: '2147483646'
看到这个错误结果的第一反应是
2
31
−
2
2^{31}-2
231−2,果然需要long long
但是
Diagnostics
Diagnostics detected issues [cpp.g++17-drmemory]: ~~Dr.M~~ Dr. Memory version 1.11.0
~~Dr.M~~ Running "b5fd26c7d19d5859b700a557341455a3.exe"
~~Dr.M~~
~~Dr.M~~ Error #1: UNINITIALIZED READ: reading register edx
~~Dr.M~~ # 0 solve [K:\ramdisk\codeforces61\4ad8d721dae2d53b30b8687338872543\compile-c0fafa8301f543b35bf9a11810ece84d/p71.cpp:10]
~~Dr.M~~ # 1 main [K:\ramdisk\codeforces61\4ad8d721dae2d53b30b8687338872543\compile-c0fafa8301f543b35bf9a11810ece84d/p71.cpp:18]
~~Dr.M~~ Note: @0:00:00.424 in thread 5072
~~Dr.M~~ Note: instruction: cmp %edx %eax
~~Dr.M~~
~~Dr.M~~ TERMINATING PROCESS after first error found
~~Dr.M~~
~~Dr.M~~ ERRORS FOUND:
~~Dr.M~~ 0 unique, 0 total unaddressable access(es)
~~Dr.M~~ 1 unique, 1 total uninitialized access(es)
~~Dr.M~~ 0 unique, 0 total invalid heap argument(s)
~~Dr.M~~ 0 unique, 0 total GDI usage error(s)
~~Dr.M~~ 0 unique, 0 total handle leak(s)
~~Dr.M~~ 0 unique, 0 total warning(s)
~~Dr.M~~ 0 unique, 0 total, 0 byte(s) of leak(s)
~~Dr.M~~ 0 unique, 0 total, 0 byte(s) of possible leak(s)
~~Dr.M~~ ERRORS IGNORED:
~~Dr.M~~ 2 potential error(s) (suspected false positives)
~~Dr.M~~ (details: K:\ramdisk\codeforces61\4ad8d721dae2d53b30b8687338872543\check-b5b636a8cdb049059bd016b36588ab49\run\DrMemory-b5fd26c7d19d5859b700a557341455a3.exe.4968.000\potential_errors.txt)
~~Dr.M~~ 11 unique, 11 total, 24693 byte(s) of still-reachable allocation(s)
~~Dr.M~~ (re-run with "-show_reachable" for details)
~~Dr.M~~ Details: K:\ramdisk\codeforces61\4ad8d721dae2d53b30b8687338872543\check-b5b636a8cdb049059bd016b36588ab49\run\DrMemory-b5fd26c7d19d5859b700a557341455a3.exe.4968.000\results.txt
~~Dr.M~~ WARNING: application exited with abnormal code 0xc0000005
然后cf提示
Uninitialized value usage
结果
- 我不知道为啥,是我错了,还是g++错了?
- 还有一个挺好奇的是为什么错误答案是 2 31 − 2 2^{31}-2 231−2,感觉就像是给了一个饱和操作一样.