QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#555967#8780. Training, Round 2chengning0909WA 1967ms9976kbC++111.5kb2024-09-10 13:14:092024-09-10 13:14:09

Judging History

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

  • [2024-09-10 13:14:09]
  • 评测
  • 测评结果:WA
  • 用时:1967ms
  • 内存:9976kb
  • [2024-09-10 13:14:09]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 5010;

int n, x, y, lx[N], rx[N], ly[N], ry[N], ans;
bitset<N> dp[2][N], Empty, tp;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> x >> y;
    for (int i = 1; i <= n; i++) {
        cin >> lx[i] >> rx[i] >> ly[i] >> ry[i];
    }
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        int k = i & 1, l = ly[i] - y, r = ry[i] - y;
        for (int j = 0; j <= n; j++) {
            dp[k][j] = dp[k ^ 1][j];
            if (l <= n && r >= 0 && lx[i] <= x + j && x + j <= rx[i]) {
                tp = dp[k ^ 1][j];
                if (0 <= l && l <= n) tp = (tp >> l) << l;
                if (0 <= r && r <= n) tp = (tp << (n - r)) >> (n - r);
                dp[k][j] |= tp << 1;
            }
            if (l <= n && r >= 0 && lx[i] <= x + j - 1 && x + j - 1 <= rx[i]) {
                tp = dp[k ^ 1][j - 1];
                if (0 <= l && l <= n) tp = (tp >> l) << l;
                if (0 <= r && r <= n) tp = (tp << (n - r)) >> (n - r);
                dp[k][j] |= tp;
            }
        }

        /*for (int j = 0; j <= n; j++) {
            for (int p = 0; p <= n; p++) {
                if (dp[k][j][p]) cout << i << ' ' << j << ' ' << p << '\n';
            }
        }*/

        for (int j = 0; j <= n; j++) dp[k ^ 1][j] = Empty;
    }

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (dp[n & 1][i][j]) ans = max(ans, i + j);
        }
    }
    cout << ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 1951ms
memory: 9976kb

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: 1953ms
memory: 9880kb

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: 0
Accepted
time: 1967ms
memory: 9884kb

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:

4994

result:

ok single line: '4994'

Test #5:

score: -100
Wrong Answer
time: 1932ms
memory: 9952kb

input:

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

output:

5000

result:

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