QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#555957 | #8780. Training, Round 2 | chengning0909 | WA | 1964ms | 9948kb | C++11 | 1.5kb | 2024-09-10 13:08:00 | 2024-09-10 13:08:02 |
Judging History
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 (j) {
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: 5680kb
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: 1953ms
memory: 9812kb
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: 1956ms
memory: 9948kb
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: 1955ms
memory: 9944kb
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: 1964ms
memory: 9900kb
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'