QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#665574 | #2838. 2D Geometry | ticking_away# | WA | 13ms | 3808kb | C++20 | 2.3kb | 2024-10-22 14:08:59 | 2024-10-22 14:09:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ull = unsigned long long;
using ll = long long;
#define endl '\n'
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int maxn = 2e5 + 10;
const int mod = 1000000007;
#define inl inline
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define ford(i, a, b) for (int i = a; i >= b; i--)
#define forall(i, a) for (auto &i : a)
/**
____ ___ _____
/ ___| _ _ / _ \___ /
\___ \| | | | | | ||_ \
___) | |_| | |_| |__) |
|____/ \__, |\___/____/
|___/
*/
istream &operator>>(istream &in, vector<int> &v)
{
for (auto &i : v)
in >> i;
return in;
}
ostream &operator<<(ostream &out, vector<int> &v)
{
for (auto &i : v)
out << i << " ";
return out;
}
bool _output = 0;
#define int ll
struct P
{
int x, y;
P(int x, int y) : x(x), y(y) {}
P operator-(P b) { return P(x - b.x, y - b.y); }
};
int det(P a, P b)
{
return a.x * b.y - a.y * b.x;
}
void solve(int n)
{
vector<P> ps;
for (int i = 0; i < n; i++)
{
int x, y;
cin >> x >> y;
ps.push_back(P(x, y));
}
auto rand = [&]()
{
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
return rng() % n;
};
int cnt = 200;
int ans = 0;
if (n <= 2)
{
cout << n << endl;
return;
}
// cout<<"! "<<endl;
while (cnt--)
{
int x = rand(), y = rand();
// cout<<x<<" "<<y<<endl;
if (x == y)
{
// cnt++;
continue;
}
int t = 2;
for (int i = 0; i < n; i++)
{
if (i == x || i == y)
continue;
auto ta = ps[x], tb = ps[y], tc = ps[i];
if (det(tb - tc, ta - tc) == 0)
{
t++;
}
}
// cout << x << " " << y << " " << t << endl;
int res = max(0ll, 3 * t - n * 2);
ans = max(ans, res);
}
cout << ans << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int _ = 1;
if (_output)
cin >> _;
int n;
while (cin >> n)
solve(n);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3808kb
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: 13ms
memory: 3524kb
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'