QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#546183 | #8780. Training, Round 2 | Djangle162857 | WA | 11ms | 101052kb | C++23 | 2.5kb | 2024-09-03 20:36:59 | 2024-09-03 20:36:59 |
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;
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 -= sty;
b[i].fir -= stx;
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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
Wrong Answer
time: 11ms
memory: 101052kb
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:
0
result:
wrong answer 1st lines differ - expected: '5000', found: '0'