QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#649422 | #5426. Drain the Water Tank | NCl3 | WA | 0ms | 3852kb | C++20 | 2.4kb | 2024-10-17 23:28:49 | 2024-10-17 23:28:50 |
Judging History
answer
#include <bits/stdc++.h>
//DEBUG: https://github.com/sharkdp/dbg-macro
#ifdef LOCAL
#include "../dbg-macro-0.5.1/dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
#define endl '\n'
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef long double llf;
const ll MAXN = 2e5 + 10, MOD = 998244353, INF = 1e9;
ll qpow(ll base, ll exp) { ll ans = 1;while (exp) { if (exp & 1)(ans *= base) %= MOD;(base *= base) %= MOD;exp >>= 1; }return ans; }
template<class T>ll max_binary_answer(ll l, ll r, T check, bool cmp = true) { ll m;while (l < r) { m = (l + r + 1) / 2;if (cmp ^ !check(m))l = m;else r = m - 1; }return l; }
template<class T>ll min_binary_answer(ll l, ll r, T check, bool cmp = true) { ll m;while (l < r) { m = (l + r) / 2;if (cmp ^ !check(m))r = m;else l = m + 1; }return r; }
ll exgcd(ll a, ll b, ll& x, ll& y) { ll tmp;return b == 0 ? (x = 1, y = 0, a) : (tmp = exgcd(b, a % b, y, x), y -= (a / b) * x, tmp); }
ll highbit(ll x) { for (ll i = 1;i < (ll)sizeof(ll) * 4;i <<= 1)x |= x >> i;return x - (x >> 1); }
ll lowbit(ll x) { return x & (-x); }
//--------Global declared area--------
ll cross(pair<ll, ll> x, pair<ll, ll> y, pair<ll, ll> z) {
//x1*y2-x2*y1
return (x.first - y.first) * (z.second - y.second) - (z.first - y.first) * (x.second - y.second);
}
void p(pair<ll, ll> x) {
cout << x.first << ',' << x.second << endl;
}
//--------Global declared end --------
void solve(int test_num) {
int n, ans = 1;
cin >> n;
vector<pair<ll, ll>> a(2 * n);
for (int i = 0;i < n;i++) {
cin >> a[i].first >> a[i].second;
a[i + n] = a[i];
}
int r = 0;
bool f = 0;
while (r < n) {
ll tmp = cross(a[(r - 1 + n) % n], a[r], a[(r + 1) % n]);
if (a[r].first < a[(r + 1)].first && a[(r + 1) % n].second > a[r].second ) {
f = 1;
}
if (a[(r - 1 + n) % n].second <= a[r].second && a[(r + 1) % n].second < a[r].second && (tmp > 0)) {
if(f) {
ans++;
f = 0;
}
}
r = r + 1;
}
cout << ans << endl;
}
int main() {
//std::ios::sync_with_stdio(false);
//std::cin.tie(nullptr),std::cout.tie(nullptr);
int t = 1;
//cin>>t;
for (int i = 1;i <= t;i++) {
solve(i);
//cout.flush();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
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: 3508kb
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: 3560kb
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: -100
Wrong Answer
time: 0ms
memory: 3852kb
input:
6 0 0 2 0 1 1 4 1 5 0 3 4
output:
1
result:
wrong answer 1st numbers differ - expected: '2', found: '1'