QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#674451 | #5426. Drain the Water Tank | yumingsk# | WA | 0ms | 3616kb | C++20 | 1.6kb | 2024-10-25 15:51:47 | 2024-10-25 15:51:47 |
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;
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'