QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#31968 | #2838. 2D Geometry | Vingying0# | WA | 3ms | 3852kb | C++17 | 1.3kb | 2022-05-14 12:57:58 | 2022-05-14 12:58:00 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
const int N = 2E5 + 50;
int n;
using db = long long;
using ll = long long;
struct Point
{
db x, y;
Point() = default;
Point(db x, db y) : x(x), y(y) {}
db operator^(const Point &t) const
{
return x * t.y - y * t.x;
}
Point operator-(const Point &t) const
{
return Point(x - t.x, y - t.y);
}
} p[N];
int rd(int l, int r)
{
int x = rand() % r;
return 1ll * rand() % r * x % r + 1;
}
int main()
{
srand(time(NULL));
while (scanf("%d", &n) == 1)
{
for (int i = 1; i <= n; i++)
{
int x, y;
scanf("%d%d", &x, &y);
p[i].x = x, p[i].y = y;
}
if (n <= 2) {
printf("%d\n", n);
continue;
}
ll ans = 0, tmp;
for (int cnt = 0; cnt < 30; ++cnt)
{
int x = rd(1, n), y = rd(1, n);
while (x == y)
y = rd(1, n);
long long sum = 0;
for (int i = 1; i <= n; ++i)
sum += ((p[x] - p[i]) ^ (p[y] - p[i])) == 0;
if (sum * 3 >= 2 * n)
{
ans = max(ans, sum - 2 * (n - sum));
}
}
printf("%lld\n", ans);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 3780kb
input:
3 0 0 0 1 0 2 3 0 0 0 1 1 0 6 0 0 0 1 0 2 0 3 1 1 1 2
output:
3 0 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3852kb
input:
1 0 0 2 0 0 1 1 3 0 0 0 1 0 2 3 0 0 0 1 1 0 4 3 0 0 2 3 3 3 1 4 2 3 1 1 0 3 0 2 4 0 0 0 3 0 2 0 1 5 8 6 9 2 2 3 7 4 1 5 5 2 2 4 2 6 2 7 2 0 4 5 3 7 5 4 4 4 9 4 9 9 5 5 4 5 9 5 5 4 3 1 0 5 3 2 1 2 7 2 6 2 5 2 6 7 2 7 9 0 3 8 8 4 4 3 8 6 2 8 2 5 3 5 3 8 2 0 0 2 6 2 3 8 4 2 9 2 2 2 6 4 9 6 2 1 7 6 6 5 ...
output:
1 2 3 0 1 0 4 0 2 0 0 5 0 0 0 0 0 0 0 3 0 6
result:
wrong answer 6th lines differ - expected: '1', found: '0'