QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#665526#2838. 2D Geometryticking_away#WA 14ms3604kbC++202.1kb2024-10-22 13:50:372024-10-22 13:50:37

Judging History

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

  • [2024-10-22 13:50:37]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3604kb
  • [2024-10-22 13:50:37]
  • 提交

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 = n;
    while (cnt--)
    {
        int x = rand(), y = rand();
        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 - ta, tc - ta) == 0)
            {
                t++;
            }
        }
        ans = max(0ll, 3 * t - n * 2);
    }
    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: 3604kb

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: 14ms
memory: 3592kb

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
0
0
4
0
2
0
0
5
0
0
0
0
0
0
0
0
0
6

result:

wrong answer 5th lines differ - expected: '1', found: '0'