QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#300415 | #7906. Almost Convex | ucup-team2818# | Compile Error | / | / | C++14 | 4.1kb | 2024-01-08 10:48:03 | 2024-01-08 10:48:05 |
Judging History
This is the latest submission verdict.
- [2024-01-08 10:48:05]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-01-08 10:48:03]
- Submitted
answer
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
typedef double lf;
// #define DEBUG 1
struct IO
{
#define MAXSIZE (1 << 20)
#define isdigit(x) (x >= '0' && x <= '9')
char buf[MAXSIZE], *p1, *p2;
char pbuf[MAXSIZE], *pp;
#if DEBUG
#else
IO() : p1(buf), p2(buf), pp(pbuf) {}
~IO() {fwrite(pbuf, 1, pp - pbuf, stdout);}
#endif
#define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2) ? ' ' : *p1++)
#define blank(x) (x == ' ' || x == '\n' || x == '\r' || x == '\t')
template <typename T>
void Read(T &x)
{
#if DEBUG
std::cin >> x;
#else
bool sign = 0; char ch = gc(); x = 0;
for (; !isdigit(ch); ch = gc())
if (ch == '-') sign = 1;
for (; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ 48);
if (sign) x = -x;
#endif
}
void Read(char *s)
{
#if DEBUG
std::cin >> s;
#else
char ch = gc();
for (; blank(ch); ch = gc());
for (; !blank(ch); ch = gc()) *s++ = ch;
*s = 0;
#endif
}
void Read(char &c) {for (c = gc(); blank(c); c = gc());}
void Push(const char &c)
{
#if DEBUG
putchar(c);
#else
if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
*pp++ = c;
#endif
}
template <typename T>
void Write(T x)
{
if (x < 0) x = -x, Push('-');
static T sta[35];
int top = 0;
do sta[top++] = x % 10, x /= 10; while (x);
while (top) Push(sta[--top] ^ 48);
}
template <typename T>
void Write(T x, char lst) {Write(x), Push(lst);}
} IO;
#define Read(x) IO.Read(x)
#define Write(x, y) IO.Write(x, y)
#define Put(x) IO.Push(x)
using namespace std;
const int MAXN = 2e3 + 10;
int n;
struct Point
{
lf x, y;
bool operator < (const Point u) const {return x < u.x || (x == u.x && y < u.y);}
Point operator - (const Point u) const {return (Point){x - u.x, y - u.y};}
lf operator * (const Point u) const {return x * u.x + y * u.y;}
}p[MAXN];
inline lf Mul(Point x, Point y) {return x.x * y.y - x.y * y.x;}
inline lf Dist(Point x) {return sqrt(x.x * x.x + x.y * x.y);}
int st[MAXN], top;
bool oc[MAXN];
vector <int> vex;
struct Data
{
lf a, b;
int id;
bool operator < (const Data u) const {return a > u.a;}
};
vector <Data> g;
int main()
{
// freopen("M.in", "r", stdin);
// freopen("M.out", "w", stdout);
#if DEBUG
#else
ios::sync_with_stdio(0), cin.tie(0);
#endif
Read(n);
for (int i = 1, x, y; i <= n; i++) Read(x), Read(y), p[i].x = x, p[i].y = y;
sort(p + 1, p + n + 1);
st[1] = 1, st[2] = top = 2;
for (int i = 3; i <= n; i++)
{
while (top > 1 && Mul(p[st[top]] - p[st[top - 1]], p[i] - p[st[top]]) >= 0) top--;
st[++top] = i;
}
for (int i = 1; i <= top; i++) vex.push_back(st[i]), oc[st[i]] = 1;
st[1] = 1, st[2] = top = 2;
for (int i = 3; i <= n; i++)
{
while (top > 1 && Mul(p[st[top]] - p[st[top - 1]], p[i] - p[st[top]]) <= 0) top--;
st[++top] = i;
}
for (int i = top - 1; i > 1; i--) vex.push_back(st[i]), oc[st[i]] = 1;
// for (auto x : vex) cout << x << " "; cout << "\n";
ll ans = 1;
for (int i = 0; i < vex.size(); i++)
{
Point A = p[vex[i]], B = p[vex[(i == vex.size() - 1 ? 0 : i + 1)]];
lf dstAB = Dist(A - B);
g.clear();
for (int j = 1; j <= n; j++)
{
if (oc[j]) continue;
g.push_back(Data{(B - A) * (p[j] - A) / Dist(A - p[j]) / dstAB, (A - B) * (p[j] - B) / Dist(B - p[j]) / dstAB, j});
}
sort(g.begin(), g.end());
// cout << i << ": " << A.x << " " << A.y << " " << B.x << " " << B.y << "\n";
// for (auto it : g) cout << it.a << " " << it.b << " " << it.id << "\n";
lf mx = -1e18;
for (auto it : g)
if (mx < it.b) ans++, mx = it.b;
}
cout << ans << "\n";
return 0;
}
Details
answer.code: In function ‘lf Dist(Point)’: answer.code:89:33: error: ‘sqrt’ was not declared in this scope 89 | inline lf Dist(Point x) {return sqrt(x.x * x.x + x.y * x.y);} | ^~~~