QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#555782#8780. Training, Round 2chengning0909TL 1ms5624kbC++141.2kb2024-09-10 09:51:162024-09-10 09:51:17

Judging History

This is the latest submission verdict.

  • [2024-09-10 09:51:17]
  • Judged
  • Verdict: TL
  • Time: 1ms
  • Memory: 5624kb
  • [2024-09-10 09:51:16]
  • Submitted

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;

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;
        for (int j = 0; j <= n; j++) {
            dp[k][j] = dp[k ^ 1][j];
            if (lx[i] <= x + j && x + j <= rx[i]) {
                dp[k][j] |= (dp[k ^ 1][j] << 1) | (dp[k ^ 1][j - 1]);
            }
        }

        if (0 <= ly[i] - y && ly[i] - y <= n && 0 <= ry[i] - y && ry[i] - y <= n) {
            int l = ly[i] - y, r = ry[i] - y;
            for (int j = 0; j <= n; j++) {
                dp[k][j] = (dp[k][j] >> l) << l;
                dp[k][j] = (dp[k][j] << (n - r)) >> (n - r);
                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: 5624kb

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: -100
Time Limit Exceeded

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:


result: