QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#873132 | #9434. Italian Cuisine | Godwang | Compile Error | / | / | C++23 | 4.2kb | 2025-01-26 09:44:38 | 2025-01-26 09:44:39 |
Judging History
answer
#include <iostream>
using namespace std;
#include <set>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <ctype.h>
#include <vector>
#include <random>
#include<list>
#define double __int128
#define ll __int128
#define ull unsigned long long
#define pb push_back
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define lowbit(x) ((x)&(-x))
ll extend_gcd(ll a, ll b, ll &x, ll &y)
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
ll d = extend_gcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
ll fastpow(ll a, ll n, ll mod)
{
ll ans = 1;
a %= mod;
while (n)
{
if (n & 1)
ans = (ans * a) % mod; //% mod
a = (a * a) % mod; //% mod
n >>= 1;
}
return ans;
}
inline void write(__int128 x)
{
if (x > 9)
{
write(x / 10);
}
putchar(x % 10 + '0');
}
struct Point
{
double x,y;
Point()
{
}
Point(double x,double y):x(x),y(y)
{
}
Point operator + (Point B)
{
return Point(x+B.x,y+B.y);
}
Point operator - (Point B)
{
return Point(x-B.x,y-B.y);
}
};
typedef Point Vector;
double Cross(Vector A,Vector B)//叉积
{
return A.x*B.y-A.y*B.x;
}
int Convex_hull(Point *p,int n,Point *ch)
{
n=unique(p,p+n)-p;
sort(p,p+n);
int v=0;
for(int i=0;i<n;i++)
{
while (v>1&&sgn(Cross(ch[v-1]-ch[v-2],p[i]-ch[v-1]))<=0)
{
v--;
}
ch[v++]=p[i];
}
int j=v;
for(int i=n-2;i>=0;i--)
{
while (v>j&&sgn(Cross(ch[v-1]-ch[v-2],p[i]-ch[v-1]))<=0)
{
v--;
}
ch[v++]=p[i];
}
if(n>1)
{
v--;
}
return v;
}
int dir[4][2] =
{
{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // 左右上下
// int dir[8][2]={
// {-1, 0}, {0, 1}, {1, 0}, {0, -1},{-1,-1},{-1,1},{1,-1},{1,1}
// };
const ll inf = LONG_LONG_MAX;
const ll mod1 = 998244353ll, P1 = 131, mod2 = 1e9 + 7ll, P2 = 13331;
ll inverse(ll x)
{
return fastpow(x,mod1-2,mod1);
}
const int N = 1e6 + 10, M = 1e6 + 10;
///////////////////////////////////
int tt;
int n;
Point p[N],ch[N],c;
ll R;
///////////////////////////////////
inline ll read()
{
ll x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0' && ch<='9')
x=x*10+ch-'0',ch=getchar();
return x*f;
}
///////////////////////////////////
void init()
{
}
///////////////////////////////////
int main()
{
// freopen("ain.txt", "r", stdin); freopen("aout.txt", "w", stdout);
cin>>tt;
while (tt--)
{
n=read();
c.x=read();
c.y=read();
R=read();
rep(i,0,n-1)
{
p[i].x=read();
p[i].y=read();
}
int v=Convex_hull(p,n,ch);
ll ans=0;
int r=1,rr=2;
ll S=0;
rep(leftt,0,v-1)
{
while (1)
{
rr=(r+1)%v;
ll temp=Cross(c-ch[rr],ch[leftt]-ch[rr]);
if(temp<0)
{
break;
}
ll dis=(ch[leftt].x-ch[rr].x)*(ch[leftt].x-ch[rr].x)+(ch[leftt].y-ch[rr].y)*(ch[leftt].y-ch[rr].y);
if(Cross(ch[leftt]-ch[rr],c-ch[rr])*Cross(ch[leftt]-ch[rr],c-ch[rr])<dis*R*R)
{
break;
}
S+=Cross(ch[leftt]-ch[rr],ch[r]-ch[rr]);
ans=max(ans,S);
r=rr;
}
int nxtleftt=(leftt+1)%v;
S-=Cross(ch[leftt]-ch[r],ch[nxtleftt]-ch[r]);
}
write(ans);
putchar('\n');
}
return 0;
}
详细
answer.code: In function ‘int Convex_hull(Point*, int, Point*)’: answer.code:100:21: error: ‘sgn’ was not declared in this scope; did you mean ‘sin’? 100 | while (v>1&&sgn(Cross(ch[v-1]-ch[v-2],p[i]-ch[v-1]))<=0) | ^~~ | sin answer.code:111:21: error: ‘sgn’ was not declared in this scope; did you mean ‘sin’? 111 | while (v>j&&sgn(Cross(ch[v-1]-ch[v-2],p[i]-ch[v-1]))<=0) | ^~~ | sin answer.code: At global scope: answer.code:132:16: error: ‘LONG_LONG_MAX’ was not declared in this scope 132 | const ll inf = LONG_LONG_MAX; | ^~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from answer.code:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of ‘constexpr bool __gnu_cxx::__ops::_Iter_equal_to_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = Point*; _Iterator2 = Point*]’: /usr/include/c++/14/bits/stl_algo.h:869:20: required from ‘constexpr _ForwardIterator std::__unique(_ForwardIterator, _ForwardIterator, _BinaryPredicate) [with _ForwardIterator = Point*; _BinaryPredicate = __gnu_cxx::__ops::_Iter_equal_to_iter]’ 869 | if (!__binary_pred(__dest, __first)) | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:900:27: required from ‘constexpr _FIter std::unique(_FIter, _FIter) [with _FIter = Point*]’ 900 | return std::__unique(__first, __last, | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 901 | __gnu_cxx::__ops::__iter_equal_to_iter()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:94:13: required from here 94 | n=unique(p,p+n)-p; | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:117:23: error: no match for ‘operator==’ (operand types are ‘Point’ and ‘Point’) 117 | { return *__it1 == *__it2; } | ~~~~~~~^~~~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1169:5: note: candidate: ‘template<class _IteratorL, class _IteratorR, class _Container> constexpr bool __gnu_cxx::operator==(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&) requires requires{{__gnu_cxx::operator==::__lhs->base() == __gnu_cxx::operator==::__rhs->base()} -> decltype(auto) [requires std::convertible_to<<placeholder>, bool>];}’ (reversed) 1169 | operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1169:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:117:23: note: ‘Point’ is not derived from ‘const __gnu_cxx::__normal_iterator<_IteratorL, _Container>’ 117 | { return *__it1 == *__it2; } | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1188:5: note: candidate: ‘template<class _Iterator, class _Container> constexpr bool __gnu_cxx::operator==(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&) requires requires{{__gnu_cxx::operator==::__lhs->base() == __gnu_cxx::operator==::__rhs->base()} -> decltype(auto) [requires std::convertible_to<<placeholder>, bool>];}’ 1188 | operator==(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1188:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:117:23: note: ‘Point’ is not derived from ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’ 117 | { return *__it1 == *__it2; } | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of ‘constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = Point*; _Iterator2 = Point*]’: /usr/include/c++/14/bits/stl_algo.h:1777:14: required from ‘constexpr void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = Point*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’ 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from ‘constexpr void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = Point*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’ 1817 | std::__insertion_sort(__first, _...