QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#719300 | #5426. Drain the Water Tank | XiaoYang3 | WA | 1ms | 3524kb | C++23 | 1.6kb | 2024-11-07 00:06:52 | 2024-11-07 00:06:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
ll n, m, k, ans;
const int N = 4e6 + 5;
const int P = 1e9 + 7;
void solve() {
cin >> n;
vector<pii> ve(n + 2);
for (int i = 0; i < n; i++) {
cin >> ve[i].first >> ve[i].second;
}
for (int i = 0; i < n; i++) {
int pre = (i + n - 1) % n;
int j = (i + 1) % n;
while (ve[i].second == ve[j].second) {
j = (j + 1) % n;
}
if (ve[i].second >= ve[j].second || ve[pre].second <= ve[i].second) {
continue;
}
// cout << pre << i << j << '\n';
if (ve[i].first == ve[pre].first && ve[i].first == ve[pre].first) {
continue;
}
if (ve[i].second != ve[(i + 1) % n].second) {
if (ve[i].first < ve[j].first || ve[pre].first < ve[i].first) {
ans++;
if (ve[pre].first < ve[i].first && ve[i].first > ve[j].first &&
ve[pre].second > ve[j].second) {
ans--;
} else if (ve[i].first < ve[pre].first &&
ve[i].first < ve[j].first &&
ve[j].second > ve[pre].second) {
ans--;
}
}
} else {
if (ve[(i + 1) % n].first > ve[i].first) {
ans++;
}
}
}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int _ = 1;
// cin >> _;
while (_--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3524kb
input:
6 0 0 1 1 2 1 3 0 3 2 0 2
output:
1
result:
wrong answer 1st numbers differ - expected: '2', found: '1'