QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#680703#8780. Training, Round 2ahsoltan#WA 981ms9664kbC++201.8kb2024-10-26 22:14:532024-10-26 22:14:53

Judging History

This is the latest submission verdict.

  • [2024-10-26 22:14:53]
  • Judged
  • Verdict: WA
  • Time: 981ms
  • Memory: 9664kb
  • [2024-10-26 22:14:53]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) int((x).size())
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

#ifdef LOCAL
auto operator<<(auto& o, auto x) -> decltype(x.first, o);
auto operator<<(auto& o, auto x) -> decltype(x.end(), o) {
  o << "{";
  for (int i = 0; auto y : x) o << ", " + !i++ * 2 << y;
  return o << "}";
}
auto operator<<(auto& o, auto x) -> decltype(x.first, o) {
  return o << "(" << x.first << ", " << x.second << ")";
}
void __print(auto... x) { ((cerr << x << " "), ...) << endl; }
#define debug(x...) __print("[" #x "]:", x)
#else
#define debug(...) 2137
#endif

constexpr int sz = 5010;
using B = bitset<sz + 1>;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, a, b;
  cin >> n >> a >> b;

  vector<tuple<int, int, int, int>> v;

  for(int i = 0; i < n; i++) {
    int a0, a1, b0, b1;
    cin >> a0 >> a1 >> b0 >> b1;
    a0 -= a;
    a1 -= a;
    b0 -= b;
    b1 -= b;
    if(a0 > sz || b0 > sz)
      continue;
    a1 = min(a1, sz);
    b1 = min(b1, sz);
    v.emplace_back(a0, a1, b0, b1);
  }

  vector<B> dp(sz + 1, B());
  auto dp2 = dp;
  dp[0][0] = 1;

  for(auto [a0, a1, b0, b1] : v) {
    for(auto &i : dp2)
      i.reset();
    B good;
    good.reset();
    for(int i = b0; i <= b1; i++)
      good[i] = 1;
    for(int i = a0; i <= min(a1 + 1, sz); i++) {
      if(i)  {
        debug(i, i - 1);
        dp2[i] |= dp[i - 1] & good;
      }
      if(i <= a1)
        dp2[i] |= (dp[i] & good) << 1;
    }
    swap(dp, dp2);
  }

  int mx = 0;

  for(int i = 0; i <= sz; i++) {
    for(int j = 0; j <= sz; j++) {
      if(dp[i][j])
        mx = max(mx, i + j);
    }
  }

  cout << mx << endl;
}

詳細信息

Test #1:

score: 100
Accepted
time: 25ms
memory: 9376kb

input:

3 0 0
0 1 0 1
1 1 0 1
1 1 1 1

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 981ms
memory: 9664kb

input:

5000 801577551 932138594
801577551 801577551 932138594 932138594
801577552 801577552 932138594 932138594
801577552 801577552 932138595 932138595
801577552 801577552 932138596 932138596
801577553 801577553 932138596 932138596
801577553 801577553 932138597 932138597
801577553 801577553 932138598 93213...

output:

5000

result:

ok single line: '5000'

Test #3:

score: 0
Accepted
time: 979ms
memory: 9628kb

input:

5000 932138594 801577551
932138594 932138594 801577551 801577551
932138594 932138594 801577552 801577552
932138595 932138595 801577552 801577552
932138596 932138596 801577552 801577552
932138596 932138596 801577553 801577553
932138597 932138597 801577553 801577553
932138598 932138598 801577553 80157...

output:

5000

result:

ok single line: '5000'

Test #4:

score: -100
Wrong Answer
time: 979ms
memory: 9632kb

input:

5000 76836128 716580777
76836128 76836128 716580777 716580777
76836129 76836129 716580777 716580777
76836130 76836130 716580777 716580777
76836131 76836131 716580777 716580777
76836131 76836131 716580778 716580778
76836131 76836131 716580779 716580779
76836131 76836131 716580780 716580780
76836128 7...

output:

0

result:

wrong answer 1st lines differ - expected: '4994', found: '0'