为什么这个代码能在我的电脑上运行,到洛谷上就CE?

P1168 中位数

@[wsdyz2010](/user/575302) ```cpp priority_queue<int,vector<int> > priority_queue<int,vector<int>,greater<int> > q2; ```
by Etinorally @ 2023-04-05 12:44:40


这里是我没复制进去
by wsdyz2010 @ 2023-04-05 12:51:30


显示的是 ``` /tmp/compiler_4fw8jghu/src: 在函数‘int main()’中: /tmp/compiler_4fw8jghu/src:16:33: 错误:调用重载的‘abs(std::priority_queue<int, std::vector<int> >::size_type)’有歧义 16 | while (abs(q1.size()-q2.size())>1) | ^ In file included from /nix/store/496xlqhx1mk41sdmrl58xi5y4pa0alys-luogu-gcc-9.3.0/include/c++/9.3.0/bits/std_abs.h:38, from /nix/store/496xlqhx1mk41sdmrl58xi5y4pa0alys-luogu-gcc-9.3.0/include/c++/9.3.0/cmath:47, from /nix/store/496xlqhx1mk41sdmrl58xi5y4pa0alys-luogu-gcc-9.3.0/include/c++/9.3.0/x86_64-unknown-linux-gnu/bits/stdc++.h:41, from /tmp/compiler_4fw8jghu/src:2: /nix/store/7rfaw11na5ajdgwr55ffzwfibbrdpk8z-glibc-2.33-56-dev/include/stdlib.h:840:12: 附注:candidate: ‘int abs(int)’ 840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ In file included from /nix/store/496xlqhx1mk41sdmrl58xi5y4pa0alys-luogu-gcc-9.3.0/include/c++/9.3.0/cmath:47, from /nix/store/496xlqhx1mk41sdmrl58xi5y4pa0alys-luogu-gcc-9.3.0/include/c++/9.3.0/x86_64-unknown-linux-gnu/bits/stdc++.h:41, from /tmp/compiler_4fw8jghu/src:2: /nix/store/496xlqhx1mk41sdmrl58xi5y4pa0alys-luogu-gcc-9.3.0/include/c++/9.3.0/bits/std_abs.h:79:3: 附注:candidate: ‘constexpr long double std::abs(long double)’ 79 | abs(long double __x) | ^~~ /nix/store/496xlqhx1mk41sdmrl58xi5y4pa0alys-luogu-gcc-9.3.0/include/c++/9.3.0/bits/std_abs.h:75:3: 附注:candidate: ‘constexpr float std::abs(float)’ 75 | abs(float __x) | ^~~ /nix/store/496xlqhx1mk41sdmrl58xi5y4pa0alys-luogu-gcc-9.3.0/include/c++/9.3.0/bits/std_abs.h:71:3: 附注:candidate: ‘constexpr double std::abs(double)’ 71 | abs(double __x) | ^~~ /nix/store/496xlqhx1mk41sdmrl58xi5y4pa0alys-luogu-gcc-9.3.0/include/c++/9.3.0/bits/std_abs.h:61:3: 附注:candidate: ‘long long int std::abs(long long int)’ 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /nix/store/496xlqhx1mk41sdmrl58xi5y4pa0alys-luogu-gcc-9.3.0/include/c++/9.3.0/bits/std_abs.h:56:3: 附注:candidate: ‘long int std::abs(long int)’ 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ ```
by wsdyz2010 @ 2023-04-05 12:52:06


`abs(int(q1.size())-int(q2.size()))>1`
by andyli @ 2023-04-05 12:57:57


编译器的提示是abs不能确定size()的类型 ```cpp int size=q1.size()-q2.size(); while (abs(size)>1) ```
by pxlamda @ 2023-04-27 21:58:17


@[pxlamda](/user/715342) 谢谢
by wsdyz2010 @ 2023-04-30 09:56:59


|