QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#590843 | #8780. Training, Round 2 | Life Sucks 人生,很搞笑吧 (Jingbang Chen, Yu Gao, Yinuo Lin)# | WA | 32ms | 101780kb | C++20 | 1.4kb | 2024-09-26 12:01:09 | 2024-09-26 12:01:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int dp[5010][5010];
int min_x[5010], max_x[5010], min_y[5010], max_y[5010];
bool ok(int x, int y, int min_x, int max_x, int min_y, int max_y) {
return min_x <= x && x <= max_x && min_y <= y && y <= max_y;
}
int main() {
int n, x, y;
scanf("%d%d%d", &n, &x, &y);
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n; j++) {
dp[i][j] = -1e9;
}
}
for (int i = 1; i <= n; i++) {
scanf("%d%d%d%d", &min_x[i], &max_x[i], &min_y[i], &max_y[i]);
}
if (ok(x, y, min_x[1], max_x[1], min_y[1], max_y[1])) {
dp[1][0] = 1;
dp[1][1] = 1;
} else {
dp[1][0] = 0;
dp[1][1] = 0;
}
for (int i = 1; i < n; i++) {
for (int j = 0; j <= i; j++) {
// printf("dp[%d][%d] = %d\n", i, j, dp[i][j]);
int now_x = x + j;
int now_y = y + i - j;
if (ok(now_x, now_y, min_x[i + 1], max_x[i + 1], min_y[i + 1],
max_y[i + 1])) {
// printf("%d,%d --> %d, %d\n", i, j, i + 1, j);
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + 1);
dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
} else {
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j]);
}
}
}
int ans = 0;
for (int i = 0; i <= n; i++) {
ans = max(ans, dp[n][i]);
}
printf("%d\n", ans);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3928kb
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: 32ms
memory: 101672kb
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: 24ms
memory: 101780kb
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: 16ms
memory: 101668kb
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:
7
result:
wrong answer 1st lines differ - expected: '4994', found: '7'