QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#463176#1169. Generate The Arrayalpha1022WA 40ms7372kbC++142.5kb2024-07-04 15:04:372024-07-04 15:04:37

Judging History

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

  • [2024-07-04 15:04:37]
  • 评测
  • 测评结果:WA
  • 用时:40ms
  • 内存:7372kb
  • [2024-07-04 15:04:37]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using L = __int128;

const ll inf = 0x3f3f3f3f3f3f3f3f;

const int N = 300;

int n;
int w[N + 5][N + 5];
int query(int x0, int x1, int y0, int y1) {
  return w[x1][y1] - w[x0 - 1][y1] - w[x1][y0 - 1] + w[x0 - 1][y0 - 1];
}
ll f[N + 5][N + 5];

struct point {
  ll x, y;
  point(ll x = 0, ll y = 0) : x(x), y(y) {}
  friend bool operator<(const point &a, const point &b) {
    return a.x != b.x ? a.x < b.x : a.y < b.y;
  }
  friend bool operator==(const point &a, const point &b) {
    return a.x == b.x && a.y == b.y;
  }
  friend point operator+(const point &a, const point &b) {
    return point(a.x + b.x, a.y + b.y);
  }
  friend point operator-(const point &a, const point &b) {
    return point(a.x - b.x, a.y - b.y);
  }
  point &operator+=(const point &o) { return *this = *this + o; }
  point &operator-=(const point &o) { return *this = *this - o; }
  friend L cross(const point &a, const point &b) {
    return (L)a.x * b.y - (L)a.y * b.x;
  }
  friend ll dot(const point &a, const point &b) {
    return a.x * b.x + a.y * b.y;
  }
};

vector<point> convexHull(vector<point> a) {
  if (a.empty()) return {};
  if (!is_sorted(a.begin(), a.end())) sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  vector<point> ret;
  for (auto i : a) {
    for (; ret.size() > 1 && cross(ret.back() - ret[ret.size() - 2], i - ret.back()) >= 0; ret.pop_back());
    ret.push_back(i);
  }
  return ret;
}
ll eval(const vector<point> &a, int &i, point p) {
  for (; i + 1 < a.size() && dot(a[i + 1] - a[i], p) > 0; ++i);
  return dot(a[i], p);
}

vector<point> vec[N + 5];
int pos[N + 5];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; ++j)
      scanf("%d", w[i] + j);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      w[i][j] += w[i - 1][j] + w[i][j - 1] - w[i - 1][j - 1];
  for (int i = 1; i <= n; ++i) {
    int k; scanf("%d", &k), vec[i].resize(k);
    for (auto &[x, y] : vec[i]) scanf("%lld%lld", &x, &y), y *= -1;
  }
  memset(f, -0x3f, sizeof f);
  for (int i = 1; i <= n + 1; ++i) f[i][i - 1] = 0;
  for (int l = n; l; --l) {
    fill_n(pos + 1, n, 0);
    for (int r = l; r <= n; ++r)
      for (int i = l; i <= r; ++i)
        if (f[l][i - 1] > -inf && f[i + 1][r] > -inf)
          f[l][r] = max(f[l][r], f[l][i - 1] + f[i + 1][r] + eval(vec[i], pos[i], {query(l, i, i, r), 1}));
  }
  printf("%lld\n", f[1][n]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4556kb

input:

5
1 0 2 2 0
0 2 2 0
2 2 2
1 2
0
2
0 27
1 19
2
7 25
1 1
2
8 7
4 18
2
8 7
4 4
2
0 25
4 26

output:

78

result:

ok 1 number(s): "78"

Test #2:

score: 0
Accepted
time: 1ms
memory: 4572kb

input:

2
1 1
1
2
1 100
2 50
1
1 100

output:

-145

result:

ok 1 number(s): "-145"

Test #3:

score: -100
Wrong Answer
time: 40ms
memory: 7372kb

input:

300
791 246 453 104 979 932 79 625 573 836 378 302 70 70 5 424 656 262 799 471 107 998 874 452 227 26 435 896 816 466 372 596 212 931 459 879 265 686 216 996 553 304 547 680 540 961 931 16 549 445 512 545 781 542 930 295 247 359 927 631 978 738 409 364 443 980 286 13 576 356 462 909 821 703 489 10 5...

output:

444026866656

result:

wrong answer 1st numbers differ - expected: '451781489678', found: '444026866656'