QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#137631 | #2350. Integer Cow | dzy521 | Compile Error | / | / | C++23 | 6.8kb | 2023-08-10 14:58:06 | 2023-08-10 14:58:09 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-08-10 14:58:09]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-10 14:58:06]
- 提交
answer
#define _CRT_SEstartE_NO_DEPRECATE
#pragma warning(disable : 4996)
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
#define ACcode ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e6 + 7;
const ll maxm = 7e6 + 7;
constexpr ll mod = 998244353;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int Prime = 100007;
const double eps = 1e-10;
const double pi = acos(-1.0);
using namespace std;
using point_t = long long;
template <typename T>
struct point
{
T x, y;
point() {}
point(T _x, T _y) { x = _x, y = _y; }
point operator+(const point &b) const { return {x + b.x, y + b.y}; }
point operator-(const point &b) const { return {x - b.x, y - b.y}; }
point operator/(const T &k) const { return {x / k, y / k}; }
point operator*(const T &k) const { return {x * k, y * k}; }
T operator*(const point &b) const { return (x * b.x + y * b.y); }
T operator^(const point &b) const { return x * b.y - y * b.x; }
// 浮点数运算
T len2() const { return (*this) * (*this); }
T dis2(const point &a) const { return (a - (*this)).len2(); }
long double len() const { return sqrtl(len2()); }
long double dis(const point &a) const { return sqrtl(dis2(a)); }
};
using Point = point<point_t>;
template <typename T>
struct line
{
point<T> p, v; // 直线上一点和方向向量
line() {}
line(T k, T b) { p = {0, b}, v = {1, k}; }
line(point<T> _p, point<T> _v) { p = _p, v = _v; }
point<T> proj(const point<T> &a) const // 点在直线上的投影
{
return p + v * ((v * (a - p)) / (v * v));
}
long double dis(const point<T> &a) const // 点到直线距离
{
return abs(v ^ (a - p)) / v.len();
}
};
using Line = line<point_t>;
struct Circle
{
Point c;
long double r;
// 点与圆的关系
// -1 圆上 | 0 圆外 | 1 圆内
int is_in(const Point &p) const
{
const long double d = p.dis(c);
return abs(d - r) <= eps ? -1 : d < r - eps;
}
// 直线与圆关系
// 0 相离 | 1 相切 | 2 相交
int relation(const Line &l) const
{
const long double d = l.dis(c);
if (d > r + eps)
return 0;
if (abs(d - r) <= eps)
return 1;
return 2;
}
// 直线与圆的交点
vector<Point> inter(const Line &l) const
{
const long double d = l.dis(c);
const Point p = l.proj(c);
const int t = relation(l);
if (t == 0)
return vector<Point>();
if (t == 1)
return vector<Point>{p};
const long double k = sqrt(r * r - d * d);
return vector<Point>{p - (l.v / l.v.len()) * k, p + (l.v / l.v.len()) * k};
}
};
void solve()
{
cout << fixed << setprecision(0);
Point pc;
Circle cir;
cin >> cir.c.x >> cir.c.y >> cir.r >> pc.x >> pc.y;
if (cir.is_in(pc) != 0)
{
cout << 0 << '\n';
cout << pc.x << " " << pc.y << '\n';
return;
}
Line l1(pc, {pc.x - cir.c.x, pc.y - cir.c.y});
vector<Point> temp = cir.inter(l1);
Point cro;
if (pc.dis2(temp[0]) < pc.dis2(temp[1]))
cro = temp[0];
else
cro = temp[1];
Point ans;
ll ansdis = 4e18;
for (ll x = max(cir.c.x - cir.r, cro.x - 30000); x <= min(cir.c.x + cir.r, cro.x + 30000); x++)
{
if (cro.y >= cir.c.y)
{
ll l = cir.c.y, r = 3e9;
while (l < r)
{
ll mid = l + r >> 1;
Point now(x, mid);
if (cir.c.dis2(now) < cir.r * cir.r)
l = mid + 1;
else
r = mid;
}
for (int y = l - 20; y <= l + 20; y++)
{
Point now(x, y);
if (cir.is_in(now) != 0)
{
ll dis2 = pc.dis2(now);
if (dis2 < ansdis)
ans = now, ansdis = dis2;
}
}
}
else
{
ll l = -3e9, r = cir.c.y;
while (l < r)
{
ll mid = l + r >> 1;
Point now(x, mid);
if (cir.c.dis2(now) <= cir.r * cir.r)
r = mid;
else
l = mid + 1;
}
for (int y = l - 20; y <= l + 20; y++)
{
Point now(x, y);
if (cir.is_in(now) != 0)
{
ll dis2 = pc.dis2(now);
if (dis2 < ansdis)
ans = now, ansdis = dis2;
}
}
}
}
for (ll y = max(cir.c.y - cir.r, cro.y - 30000); y <= min(cir.c.y + cir.r, cro.y + 30000); y++)
{
if (cro.x >= cir.c.x)
{
ll l = cir.c.x, r = 3e9;
while (l < r)
{
ll mid = l + r >> 1;
Point now(mid, y);
if (cir.c.dis2(now) < cir.r * cir.r)
l = mid + 1;
else
r = mid;
}
for (int x = l - 15; x <= l + 15; x++)
{
Point now(x, y);
if (cir.is_in(now) != 0)
{
ll dis2 = pc.dis2(now);
if (dis2 < ansdis)
ans = now, ansdis = dis2;
}
}
}
else
{
ll l = -3e9, r = cir.c.y;
while (l < r)
{
ll mid = l + r >> 1;
Point now(mid, y);
if (cir.c.dis2(now) <= cir.r * cir.r)
r = mid;
else
l = mid + 1;
}
for (int x = l - 15; x <= l + 15; x++)
{
Point now(x, y);
if (cir.is_in(now) != 0)
{
ll dis2 = pc.dis2(now);
if (dis2 < ansdis)
ans = now, ansdis = dis2;
}
}
}
}
cout << 1 << '\n';
cout << pc.x << " " << pc.y << " " << ans.x << " " << ans.y << '\n';
}
signed main()
{
ACcode;
// freopen("house.in", "r", stdin);
// freopen("house.out", "w", stdout);
int t = 1;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
详细
answer.code: In function ‘void solve()’: answer.code:129:20: error: no matching function for call to ‘max(long double, long long int)’ 129 | for (ll x = max(cir.c.x - cir.r, cro.x - 30000); x <= min(cir.c.x + cir.r, cro.x + 30000); x++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/stl_tree.h:63, from /usr/include/c++/11/map:60, from answer.code:3: /usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’ 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: answer.code:129:20: note: deduced conflicting types for parameter ‘const _Tp’ (‘long double’ and ‘long long int’) 129 | for (ll x = max(cir.c.x - cir.r, cro.x - 30000); x <= min(cir.c.x + cir.r, cro.x + 30000); x++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/stl_tree.h:63, from /usr/include/c++/11/map:60, from answer.code:3: /usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: answer.code:129:20: note: deduced conflicting types for parameter ‘const _Tp’ (‘long double’ and ‘long long int’) 129 | for (ll x = max(cir.c.x - cir.r, cro.x - 30000); x <= min(cir.c.x + cir.r, cro.x + 30000); x++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/string:52, from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/fstream:38, from answer.code:6: /usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’ 3461 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3461:5: note: template argument deduction/substitution failed: answer.code:129:20: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long double’ 129 | for (ll x = max(cir.c.x - cir.r, cro.x - 30000); x <= min(cir.c.x + cir.r, cro.x + 30000); x++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/string:52, from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/fstream:38, from answer.code:6: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’ 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3467:5: note: template argument deduction/substitution failed: answer.code:129:20: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long double’ 129 | for (ll x = max(cir.c.x - cir.r, cro.x - 30000); x <= min(cir.c.x + cir.r, cro.x + 30000); x++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:129:62: error: no matching function for call to ‘min(long double, long long int)’ 129 | for (ll x = max(cir.c.x - cir.r, cro.x - 30000); x <= min(cir.c.x + cir.r, cro.x + 30000); x++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/stl_tree.h:63, from /usr/include/c++/11/map:60, from answer.code:3: /usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’ 230 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:230:5: note: template argument deduction/substitution failed: answer.code:129:62: note: deduced conflicting types for parameter ‘const _Tp’ (‘long double’ and ‘long long int’) 129 | for (ll x = max(cir.c.x - cir.r, cro.x - 30000); x <= min(cir.c.x + cir.r, cro.x + 30000); x++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/stl_tree.h:63, from /usr/include/c++/11/map:60, from answer.code:3: /usr/include/c++/11/bits/stl_...