QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#635070#9434. Italian Cuisinewoodie_0064#Compile Error//C++172.5kb2024-10-12 18:56:192024-10-12 18:56:20

Judging History

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

  • [2024-10-12 18:56:20]
  • 评测
  • [2024-10-12 18:56:19]
  • 提交

answer

#include <bits/stdc++.h>
typedef __int128 ll;
using namespace std;
const int maxn = 1e5 + 5;
int n;
ll R;
struct vec {
	ll x, y;
	vec(int x = 0, int y = 0) : x(x), y(y) {}
	friend vec operator - (const vec &p, const vec &q) {
		return vec(p.x - q.x, p.y - q.y);
	}
} a[maxn * 2], c;
ll cross(vec p, vec q) {
	return p.x * q.y - p.y * q.x;
}
void print(ll x) {
	if(x == 0) {
		cout << 0;
		return;
	}
	vector<int> res;
	while(x > 0) {
		res.push_back(x % 10);
		x /= 10;
	}
	reverse(res.begin(), res.end());
	for(int i : res) {
		cout << i;
	}
}
bool check(vec p, vec q) {
	// cout <<sqrt((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y)) << '\n';
	// cout << (p.y - q.y) * c.x << ' ' << (q.x - p.x) * c.y << ' ';
	// cout << abs((p.y - q.y) * c.x + (q.x - p.x) * c.y + p.x * q.y - p.y * q.x) << ' ';
	// cout << abs((p.y - q.y) * c.x + (q.x - p.x) * c.y + p.x * q.y - p.y * q.x)
	// / sqrt((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y)) << '\n';
	ll t = (p.y - q.y) * c.x + (q.x - p.x) * c.y + p.x * q.y - p.y * q.x;
	return t * t >= R * R * ((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y));
}
void solve() {
	int x, y;
	cin >> n >> x >> y;
	c = vec(x, y);
	cin >> x;
	R = x;
	for(int i = 1; i <= n; i++) {
		cin >> x >> y;
		a[i] = vec(x, y);
		a[i + n] = a[i];
	}
	ll ans = 0, sum1 = 0, sum2 = 0;
	sum1 += cross(a[1], a[1]);
	for(int i = 1; i <= n; i++) {
		sum2 += cross(a[i], a[i + 1]);
	}
	for(int i = 1, j = 1; i <= n; i++) {
		while(j + 1 - i <= n - 2 && check(a[i], a[j + 1]) && cross(a[j + 1] - a[i], c - a[i]) > 0) {
			sum1 += cross(a[j], a[j + 1]);
			sum1 -= cross(a[j], a[i]);
			sum1 += cross(a[j + 1], a[i]);
			// sum2 -= cross(a[j], a[j + 1]);
			// sum2 -= cross(a[j], a[i + n]);
			// sum2 += cross(a[j + 1], a[i + n]);
			j++;
		}
		if(i < j) {
			ans = max(ans, abs(sum1));
			// cout << i << ' ' << j << ' ' << sum1 << '\n';
			// if(cross((a[j] - a[i]), (c - a[i])) < 0) {
			// ans = max(ans, sum1 / 2);
			// }
			// else {
			// ans = max(ans, sum2 / 2);
			// }
			sum1 -= cross(a[i], a[i + 1]);
			sum1 -= cross(a[j], a[i]);
			sum1 += cross(a[j], a[i + 1]);
			// sum2 += cross(a[i + n], a[i + n + 1]);
			// sum2 -= cross(a[j], a[i + n]);
			// sum2 += cross(a[i + n + 1], a[j]);
		}
		else {
			j++;
		}
	}
	print(ans);
	cout << '\n';
}
int main() {
#ifdef yczDEBUG
	freopen("1.in", "r", stdin);
	freopen("1.out", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	int T;
	cin >> T;
	while(T--) {
		solve();
	}
	return 0;
}

详细

answer.code: In function ‘void solve()’:
answer.code:68:43: error: call of overloaded ‘abs(ll&)’ is ambiguous
   68 |                         ans = max(ans, abs(sum1));
      |                                        ~~~^~~~~~
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); }
      |   ^~~