QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55866#2838. 2D GeometryStudyingFather#WA 0ms3808kbC++201.2kb2022-10-15 14:36:302022-10-15 14:36:30

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-15 14:36:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3808kb
  • [2022-10-15 14:36:30]
  • 提交

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];
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;
  while (scanf("%d", &n) != EOF) {
    vector<pii> h;
    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: 0ms
memory: 3808kb

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
0

result:

wrong answer 3rd lines differ - expected: '0', found: ''