QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#595718#9434. Italian Cuisineucup-team4938#Compile Error//C++142.1kb2024-09-28 14:19:332024-09-28 14:19:33

Judging History

你现在查看的是最新测评结果

  • [2024-09-28 14:19:33]
  • 评测
  • [2024-09-28 14:19:33]
  • 提交

answer

#include<bits/stdc++.h>
#define int __int128
#define mod 998244353ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
using namespace std;
const int maxn=200010;
const int inf=1e18;
inline int read(){
	int 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<<3)+(x<<1)+(ch-48);ch=getchar();}
	return x*f;
}
inline void write(__int128 x){static char buf[100];static int len=-1;if(x<0)putchar('-'),x=-x;do buf[++len]=x%10,x/=10;while(x);while(len>=0)putchar(buf[len--]+48);}

bool Mbe;

int n,x,y,c;
pii a[maxn];
int calc(pii a,pii b,pii c){
	return abs(a.fi*b.se+b.fi*c.se+c.fi*a.se-a.fi*c.se-b.fi*a.se-c.fi*b.se);
}
bool chk(pii u,pii v,__int128 x,__int128 y,__int128 r){
	__int128 a=v.se-u.se,b=u.fi-v.fi,c=-a*u.fi-b*u.se;
	// cout<<a<<" "<<b<<" "<<c<<" "<<(a*u.fi+b*u.se+c==0)<<" "<<(a*v.fi+b*v.se+c==0)<<"\n";
	// int dis=(__int128)(a*x+b*y+c)*(a*x+b*y+c)/(a*a+b*b);
	// write(a*x+b*y+c),putchar(' '),write(a*a+b*b),puts("");
	// cout<<dis<<"\n";
	return (__int128)(a*x+b*y+c)*(a*x+b*y+c)>(__int128)r*r*(a*a+b*b);
}
int get(pii a,pii b,pii c){
	b.fi-=a.fi,b.se-=a.se,c.fi-=a.fi,c.se-=a.se;
	return b.fi*c.se-b.se*c.fi;
}
int ans;
void work(){
	n=read();x=read(),y=read(),c=read();ans=0;
	for(int i=1;i<=n;i++)a[i]=a[i+n]={read(),read()};
	for(int i=1,j=2,sum=0;i<=n;i++){
		while(j<=2*n){
			if(!chk(a[i],a[j],x,y,c))break;
			// cout<<i<<" "<<j<<"\n";
			if(j>i+1){
			// cout<<i<<" "<<j<<" "<<get(a[i],{x,y},a[j])<<" "<<get(a[i],{x,y},a[j-1])<<"\n";
				if((__int128)get(a[i],{x,y},a[j])*get(a[i],{x,y},a[j-1])<=0)break;
			}
			if(j>i+1)sum+=calc(a[i],a[j-1],a[j]);
			j++;
		}
		ans=max(ans,sum);
		// cout<<i<<" "<<j<<" "<<sum<<"\n";
		if(j>i+2)sum-=calc(a[i],a[i+1],a[i+2]);
		if(i+1==j)j++;
	}
	write(ans);puts("");
}

// \
444

bool Med;
int T;
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	
//	cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
	
	T=read();
	while(T--)work();
}


详细

answer.code: In function ‘__int128 calc(std::pair<__int128, __int128>, std::pair<__int128, __int128>, std::pair<__int128, __int128>)’:
answer.code:25:19: error: call of overloaded ‘abs(__int128)’ is ambiguous
   25 |         return abs(a.fi*b.se+b.fi*c.se+c.fi*a.se-a.fi*c.se-b.fi*a.se-c.fi*b.se);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:42,
                 from answer.code:1:
/usr/include/stdlib.h:840:12: note: candidate: ‘int abs(int)’
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/13/cstdlib:81:
/usr/include/c++/13/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:61:3: note: candidate: ‘long long int std::abs(long long int)’
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~