QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#674522 | #5426. Drain the Water Tank | yumingsk# | WA | 0ms | 3600kb | C++20 | 1.9kb | 2024-10-25 16:15:50 | 2024-10-25 16:15:51 |
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3600kb
input:
6 0 0 1 1 2 1 3 0 3 2 0 2
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'