QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#674519 | #5426. Drain the Water Tank | yumingsk# | WA | 0ms | 3596kb | C++20 | 1.9kb | 2024-10-25 16:15:05 | 2024-10-25 16:15:06 |
Judging History
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;
#define int long long
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(2 * n + 3);
for (int i = 1; i <= n; i++)
{
int x, y;
cin >> x >> y;
p[i] = {x, y};
p[i + n] = {x, y};
}
// vector<int> vis(2n , 0);
vector<pair<int, int>> kt(2 * n + 1);
for (int i = 1; i <= 2 * n - 1; i++)
{
kt[i] = {p[i + 1].first - p[i].first, p[i + 1].second - p[i].second};
}
// {-y,x}
int ans = 0;
int pos = 1;
for (int i = 2; i <= n; i++)
{
if (p[i].second > p[pos].second)
pos = i;
else if (p[i].second == p[pos].second)
{
if (p[i].first > p[pos].first)
pos = i;
}
}
pair<int, int> lst = p[pos];
for (int i = pos + 1; i <= pos + n; i++)
{
if (lst.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++;
}
if (kt[i].second <= 0)
lst = kt[i];
}
cout << ans << '\n';
}
signed 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: 3596kb
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: -100
Wrong Answer
time: 0ms
memory: 3548kb
input:
8 4 4 0 4 0 2 1 2 2 2 2 0 3 0 4 0
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'