QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#546187 | #8780. Training, Round 2 | Djangle162857 | WA | 58ms | 199052kb | C++23 | 2.5kb | 2024-09-03 20:40:02 | 2024-09-03 20:40:02 |
Judging History
answer
#include <bits/stdc++.h>
#define fir first
#define sec second
#define FINISH cout << "FINISH" << endl;
#define debug(x) cerr << #x << " : = " << endl;
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> PII;
const int N = 200020;
const int M = 200010;
const int inf = 0x3f3f3f3f;
int a[N], b[N], sum[N];
int dp[2][5000010];
void solve()
{
int n, stx, sty;
cin >> n >> stx >> sty;
vector<PII> a(n + 1);
vector<PII> b(n + 1);
for (int i = 1; i <= n; i++)
{
cin >> a[i].fir >> a[i].sec >> b[i].fir >> b[i].sec;
a[i].fir -= stx;
a[i].sec -= stx;
b[i].fir -= sty;
b[i].sec -= sty;
}
auto isin = [&](int x, int y, int inp)
{
if (a[inp].fir <= x && x <= a[inp].sec && b[inp].fir <= x && x <= b[inp].sec)
{
return true;
}
return false;
};
vector<vector<int>> dp(n + 1, vector<int>(n + 1, inf));
int ans = 0;
int now = 1;
for (int i = 1; i <= n; i++)
{
while (!isin(i, 0, now) && now <= n)
{
now++;
}
if (now == n + 1)
break;
dp[i][0] = now;
ans = max(ans, i);
}
for (int i = 1; i <= n; i++)
{
while (!isin(0, i, now) && now <= n)
{
now++;
}
if (now == n + 1)
break;
dp[0][i] = now;
ans = max(ans, i);
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; i + j <= n; j++)
{
if (dp[i - 1][j] != inf) {
now = dp[i - 1][j] + 1;
while (!isin(i, j, now) && now <= n)
{
now++;
}
if (now != n + 1) {
dp[i][j] = min(dp[i][j], now);
ans = max(ans, i + j);
}
}
if (dp[i][j - 1] != inf) {
now = dp[i][j - 1];
while (!isin(i, j, now) && now <= n)
{
now++;
}
if (now != n + 1) {
dp[i][j] = min(dp[i][j], now);;
ans = max(ans, i + j);
}
}
}
}
cout << ans << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
// cin >> T;
while (T--)
{
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
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: 39ms
memory: 198928kb
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: 58ms
memory: 198928kb
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: 28ms
memory: 199052kb
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'