답안 #570055

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570055 2022-05-28T13:53:14 Z 600Mihnea Nuclearia (CEOI15_nuclearia) C++17
30 / 100
1000 ms 100336 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);

  /// freopen ("input.txt", "r", stdin);

  bool Inverse = 0;

  int n, m;
  cin >> n >> m;
  if (n > m) {
    Inverse = 1;
    swap(n, m);
  }
  assert(n <= m);
  vector<vector<ll>> radiation(n + 1, vector<ll> (m + 1, 0)), v(n + 1, vector<ll> (m + 1, 0));

  int ops;
  cin >> ops;
  for (int i = 1; i <= ops; i++) {
    int r, c, a, b;
    cin >> r >> c >> a >> b;
    if (Inverse) {
      swap(r, c);
    }
    for (int r2 = 1; r2 <= n; r2++) {
      for (int c2 = 1; c2 <= m; c2++) {
        int dist = max(abs(r - r2), abs(c - c2));
        radiation[r2][c2] += max(0LL, a - 1LL * b * dist);
      }
    }

    for (int dist = 0; r + dist <= n || r - dist >= 1; dist++) {
      if (r + dist <= n) {
        int r2 = r + dist;
        for (int c2 = 1; c2 <= m; c2++) {
          int dist = max(abs(r - r2), abs(c - c2));
          v[r2][c2] += max(0LL, a - 1LL * b * dist);
        }
      }
      if (r - dist >= 1 && dist >= 1) {
        int r2 = r - dist;
        for (int c2 = 1; c2 <= m; c2++) {
          int dist = max(abs(r - r2), abs(c - c2));
          v[r2][c2] += max(0LL, a - 1LL * b * dist);
        }
      }
    }
  }
  assert(v == radiation);

  {
    /// transform the radiation in the form of prefix rectangle sum

    for (int i = 1; i <= n; i++) {
      ll cur = 0;
      for (int j = 1; j <= m; j++) {
        cur += radiation[i][j];
        radiation[i][j] = radiation[i - 1][j] + cur;
      }
    }
  }

  int q;
  cin >> q;
  while (q--) {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    if (Inverse) {
      swap(r1, c1);
      swap(r2, c2);
    }
    ll total = radiation[r2][c2] - radiation[r1 - 1][c2] - radiation[r2][c1 - 1] + radiation[r1 - 1][c1 - 1];
    ll area = (r2 - r1 + 1) * (c2 - c1 + 1);

    cout << total / area + (total % area >= area - total % area) << "\n";
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 390 ms 98176 KB Output is correct
2 Correct 64 ms 2700 KB Output is correct
3 Correct 50 ms 2296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 382 ms 98160 KB Output is correct
2 Correct 66 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 342 ms 39596 KB Output is correct
2 Correct 74 ms 2768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 370 ms 42452 KB Output is correct
2 Correct 57 ms 2588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 257 ms 100336 KB Output is correct
2 Correct 64 ms 2904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 467 ms 41840 KB Output is correct
2 Correct 65 ms 2632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 483 ms 41912 KB Output is correct
2 Correct 76 ms 2896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 442 ms 30060 KB Output is correct
2 Correct 87 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 98072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1097 ms 98040 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 39508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 39508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 40372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 39564 KB Time limit exceeded
2 Halted 0 ms 0 KB -