#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
struct Point{
int x, y;
double r;
};
int n;
const int maxl = 3000;
const double pi = acos(-1);
bool vis[6];
Point pt[6];
int x0, y0, x1, y1;
double dst(Point a, Point b){
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int fun(double a){
return a + 0.5;
}
int stdr(Point a){
int tmp = a.x - x0;
tmp = min(tmp, a.y - y0);
tmp = min(tmp, x1 - a.x);
tmp = min(tmp, y1 - a.y);
return tmp;
}
bool eq(Point a, Point b){
return a.x == b.x && a.y == b.y;
}
double sum(Point now){
now.r = stdr(now);
for(int i = 0; i < n; i++){
if(vis[i] && !eq(pt[i], now)){
now.r = min(now.r, dst(pt[i], now) - pt[i].r);
}
}
double ans = 0;
for(int i = 0; i < n; i++){
if(!vis[i]) {
vis[i] = 1;
ans = max(sum(pt[i]), ans);
vis[i] = 0;
}
}
return ans + now.r * now.r;
}
int main(){
cin >> n;
cin >> x0 >> y0 >> x1 >> y1;
if(x0 > x1) swap(x0, x1);
if(y0 > y1) swap(y0, y1);
for(int i = 0; i < n; i++){
cin >> pt[i].x >> pt[i].y;
pt[i].r = maxl;
}
double maxx = 0;
for(int i = 0; i < n; i++){
memset(vis, 0, sizeof vis);
vis[i] = 1;
pt[i].r = stdr(pt[i]);
maxx = max(sum(pt[i]), maxx);
}
cout << (x1 - x0) * (y1 - y0) - fun(maxx * pi);
}
如题,这份代码在本地编译通过,而且连警告都没有,为什么在洛谷提交是CE? 报错如下。
/tmp/compiler_xp9oq4p0/src:14:9: 错误:‘int y0’ redeclared as different kind of entity
14 | int x0, y0, x1, y1;
| ^~
In file included from /nix/store/7rfaw11na5ajdgwr55ffzwfibbrdpk8z-glibc-2.33-56-dev/include/features.h:473,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/x86_64-unknown-linux-gnu/bits/os_defines.h:39,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/x86_64-unknown-linux-gnu/bits/c++config.h:586,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/iostream:38,
from /tmp/compiler_xp9oq4p0/src:1:
/nix/store/7rfaw11na5ajdgwr55ffzwfibbrdpk8z-glibc-2.33-56-dev/include/bits/mathcalls.h:223:1: 附注:previous declaration ‘double y0(double)’
223 | __MATHCALL (y0,, (_Mdouble_));
| ^~~~~~~~~~
/tmp/compiler_xp9oq4p0/src:14:17: 错误:‘int y1’ redeclared as different kind of entity
14 | int x0, y0, x1, y1;
| ^~
In file included from /nix/store/7rfaw11na5ajdgwr55ffzwfibbrdpk8z-glibc-2.33-56-dev/include/features.h:473,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/x86_64-unknown-linux-gnu/bits/os_defines.h:39,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/x86_64-unknown-linux-gnu/bits/c++config.h:586,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/iostream:38,
from /tmp/compiler_xp9oq4p0/src:1:
/nix/store/7rfaw11na5ajdgwr55ffzwfibbrdpk8z-glibc-2.33-56-dev/include/bits/mathcalls.h:224:1: 附注:previous declaration ‘double y1(double)’
224 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
/tmp/compiler_xp9oq4p0/src: 在函数‘int stdr(Point)’中:
/tmp/compiler_xp9oq4p0/src:23:28: 错误:操作数类型‘int’和‘double(double) noexcept’ {aka ‘double(double)’}对双目‘operator-’而言无效
23 | tmp = min(tmp, a.y - y0);
| ~~~ ^ ~~
| | |
| int double(double) noexcept {aka double(double)}
/tmp/compiler_xp9oq4p0/src:25:27: 警告:在算术表达式中使用了函数指针 [-Wpointer-arith]
25 | tmp = min(tmp, y1 - a.y);
| ~~~^~~~~
/tmp/compiler_xp9oq4p0/src:25:18: 错误:对‘min(int&, double (*)(double) noexcept)’的调用没有匹配的函数
25 | tmp = min(tmp, y1 - a.y);
| ~~~^~~~~~~~~~~~~~~
In file included from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/char_traits.h:39,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ios:40,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ostream:38,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/iostream:39,
from /tmp/compiler_xp9oq4p0/src:1:
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/stl_algobase.h:230:5: 附注:candidate: ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’
230 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/stl_algobase.h:230:5: 附注: template argument deduction/substitution failed:
/tmp/compiler_xp9oq4p0/src:25:18: 附注: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘double (*)(double) noexcept’ {aka ‘double (*)(double)’})
25 | tmp = min(tmp, y1 - a.y);
| ~~~^~~~~~~~~~~~~~~
In file included from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/char_traits.h:39,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ios:40,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/ostream:38,
from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/iostream:39,
from /tmp/compiler_xp9oq4p0/src:1:
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/stl_algobase.h:278:5: 附注:candidate: ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
278 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/bits/stl_algobase.h:278:5: 附注: template argument deduction/substitution failed:
/tmp/compiler_xp9oq4p0/src:25:18: 附注: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘double (*)(double) noexcept’ {aka ‘double (*)(double)’})
25 | tmp = min(tmp, y1 - a.y);
| ~~~^~~~~~~~~~~~~~~
/tmp/compiler_xp9oq4p0/src: 在函数‘int main()’中:
/tmp/compiler_xp9oq4p0/src:50:19: 错误:no match for ‘operator>>’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘double(double) noexcept’ {aka ‘double(double)’})
50 | cin >> x0 >> y0 >> x1 >> y1;
| ~~~~~~~~~ ^~ ~~
| | |
| | double(double) noexcept {aka double(double)}
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/iostream:40,
from /tmp/compiler_xp9oq4p0/src:1:
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:120:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
120 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:120:7: 附注: conversion of argument 1 would be ill-formed:
/tmp/compiler_xp9oq4p0/src:50:22: 错误:invalid conversion from ‘double (*)(double) noexcept’ {aka ‘double (*)(double)’} to ‘std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)’ {aka ‘std::basic_istream<char>& (*)(std::basic_istream<char>&)’} [-fpermissive]
50 | cin >> x0 >> y0 >> x1 >> y1;
| ^~
| |
| double (*)(double) noexcept {aka double (*)(double)}
In file included from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/iostream:40,
from /tmp/compiler_xp9oq4p0/src:1:
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:124:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]’ (near match)
124 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:124:7: 附注: conversion of argument 1 would be ill-formed:
/tmp/compiler_xp9oq4p0/src:50:22: 错误:invalid conversion from ‘double (*)(double) noexcept’ {aka ‘double (*)(double)’} to ‘std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)’ {aka ‘std::basic_ios<char>& (*)(std::basic_ios<char>&)’} [-fpermissive]
50 | cin >> x0 >> y0 >> x1 >> y1;
| ^~
| |
| double (*)(double) noexcept {aka double (*)(double)}
In file included from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/iostream:40,
from /tmp/compiler_xp9oq4p0/src:1:
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:131:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
131 | operator>>(ios_base& (*__pf)(ios_base&))
| ^~~~~~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:131:7: 附注: conversion of argument 1 would be ill-formed:
/tmp/compiler_xp9oq4p0/src:50:22: 错误:invalid conversion from ‘double (*)(double) noexcept’ {aka ‘double (*)(double)’} to ‘std::ios_base& (*)(std::ios_base&)’ [-fpermissive]
50 | cin >> x0 >> y0 >> x1 >> y1;
| ^~
| |
| double (*)(double) noexcept {aka double (*)(double)}
In file included from /nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/iostream:40,
from /tmp/compiler_xp9oq4p0/src:1:
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:168:7: 附注:candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
168 | operator>>(bool& __n)
| ^~~~~~~~
/nix/store/fdbr19mgwzmp1f17nbd9pqjv9vl9kzrq-luogu-gcc-11.2.0/include/c++/11.2.0/istream:168:7: 附注: conversion of argument 1 would be ill-formed:
/tmp/compiler_xp9oq4p0/src:50:22: 警告:‘double y0(double)’的地址永远不会为 NULL [-Waddress]
50 | cin >> x0 >> y0 >> x1 >> y1;
| ^~
/tmp/compiler_xp9oq
...