QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#55860 | #2838. 2D Geometry | StudyingFather# | WA | 2ms | 3856kb | C++20 | 1.1kb | 2022-10-15 14:30:31 | 2022-10-15 14:30:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
const int N = 500005;
pii d[N];
vector<pii> h;
bool ok(pii a, pii b, pii c) {
if (a.fi == b.fi && b.fi == c.fi)
return false;
if (a.se == b.se && b.se == c.se)
return false;
if (a.fi == b.fi || b.fi == c.fi)
return true;
if (a.se == b.se || b.se == c.se)
return true;
if (1ll * (a.fi - b.fi) * (b.se - c.se) == 1ll * (b.fi - c.fi) * (a.se - b.se))
return false;
return true;
}
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d%d", &d[i].fi, &d[i].se);
int u = h.size();
if (u >= 2 && ok(d[i], h[u - 2], h[u - 1]))
h.resize(u - 2);
else
h.pb(d[i]);
}
if (h.size() < 2) {
printf("%d\n", n % 3);
return 0;
}
int z = 0;
for (int i = 1; i <= n; i++)
if (!ok(d[i], h[0], h[1]))
++z;
//printf("n: %d!\n", h.size());
int u = n - z;
if (z - u * 2 <= 0) {
printf("%d\n", n % 3);
return 0;
}
printf("%d\n", z - u * 2);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3856kb
input:
3 0 0 0 1 0 2 3 0 0 0 1 1 0 6 0 0 0 1 0 2 0 3 1 1 1 2
output:
3
result:
wrong answer 2nd lines differ - expected: '0', found: ''