QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#674451#5426. Drain the Water Tankyumingsk#WA 0ms3616kbC++201.6kb2024-10-25 15:51:472024-10-25 15:51:47

Judging History

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

  • [2024-10-25 15:51:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-10-25 15:51:47]
  • 提交

answer

#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";

using namespace std;
const int Mod = 998244353;
using ll = long long;
int cross(pair<int, int> s1, pair<int, int> s2)
{
    return s1.first * s2.first + s2.second * s2.second;
}
void solve()
{
    int n;
    cin >> n;
    vector<pair<int, int>> p(n + 3);
    for (int i = 1; i <= n; i++)
    {
        int x, y;
        cin >> x >> y;
        p[i] = {x, y};
    }
    p[n + 1] = p[1];
    p[n + 2] = p[2];
    vector<int> vis(n + 3, 0);
    vector<pair<int, int>> kt(n + 3);
    for (int i = 1; i <= n + 1; i++)
    {
        kt[i] = {p[i + 1].first - p[i].first, p[i + 1].second - p[i].second};
    }
    // {-y,x}
    int ans = 0;

    for (int i = 2; i <= n + 1; i++)
    {
        if (kt[i - 1].second <= 0 && kt[i].second > 0) // 向下  (x,y)
        {
            pair<int, int> tmp = {-kt[i - 1].second, kt[i - 1].first};
            if (cross(tmp, kt[i]) > 0)
                ans++;
        }
    }
    cout << ans << '\n';
}
int main()
{
    IOS;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#ifndef ONLINE_JUDGE
    clock_t start_time = clock();
#endif
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
#ifndef ONLINE_JUDGE
    cout << "Used " << (double)(clock() - start_time) << " ms" << endl;
#endif
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3588kb

input:

6
0 0
1 1
2 1
3 0
3 2
0 2

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

8
4 4
0 4
0 2
1 2
2 2
2 0
3 0
4 0

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3468kb

input:

7
1 0
3 4
0 3
1 2
2 3
1 1
0 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

6
0 0
2 0
1 1
4 1
5 0
3 4

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

8
0 0
1 0
3 -1
3 0
1 1
4 1
5 0
3 4

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3516kb

input:

5
0 0
170 0
140 30
60 30
0 70

output:

2

result:

wrong answer 1st numbers differ - expected: '1', found: '2'