QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#669195 | #8780. Training, Round 2 | argtarg# | WA | 39ms | 199028kb | C++20 | 2.8kb | 2024-10-23 17:38:58 | 2024-10-23 17:38:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void solve();
signed main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
//cin >> t;
while(t--)solve();
return 0;
}
const int inf = 1e9;
#define pii pair<int, int>
#define ft first
#define sd second
struct node
{
int lx, ux;
int ly, uy;
};
void solve()
{
int n, x, y;
cin >> n >> x >> y;
vector<node> v(n + 1);
for(int i = 1; i <= n; i++)cin >> v[i].lx >> v[i].ux >> v[i].ly >> v[i].uy;
vector<vector<int>> dp(n + 1, vector<int>(n + 1, -inf));
dp[0][0] = 0;
vector<node> q(n + 1);
for(int i = 1; i <= n; i++)
{
if(x < v[i].lx)q[i].lx = v[i].lx - x, q[i].ux = min(n, v[i].ux - x);
else if(x >= v[i].lx && x <= v[i].ux)q[i].lx = 0ll, q[i].ux = min(n, v[i].ux - x);
else q[i].lx = q[i].ux = -1;
if(y < v[i].ly)q[i].ly = v[i].ly - y, q[i].uy = min(n, v[i].uy - y);
else if(y >= v[i].ly && y <= v[i].uy)q[i].ly = 0ll, q[i].uy = min(n, v[i].uy - y);
else q[i].ly = q[i].uy = -1;
}
// for(int i = 1; i <= n; i++)
// cout << q[i].lx << ' ' << q[i].ux << endl;
// for(int i = 1; i <= n; i++)
// cout << q[i].ly << ' ' << q[i].uy << endl;
for(int i = 1; i <= n; i++)
{
dp[i] = dp[i - 1];
if(q[i].lx == -1 || q[i].ux == -1 || q[i].ly == -1 || q[i].uy == -1)continue;
// debug(q[i].lx);
// debug(q[i].ux);
// debug(q[i].ly);
// debug(q[i].uy);
auto belong = [&](int x, int y, int lx, int ux, int ly, int uy)
{
if(x >= lx && x <= ux && y >= ly && y <= uy)return true;
else return false;
};
for(int j = 1; j <= i; j++)
{
//int nowx = j, nowy = dp[i][j] - j;
// debug(nowx);
// debug(nowy);
// if(nowx >= q[i].lx && nowx <= q[i].ux && nowy >= q[i].ly && nowy <= q[i].uy)
// {
// dp[i][j] = max({dp[i][j], dp[i - 1][j] + 1, dp[i - 1][j - 1] + 1});
// }
int nowx = j - 1, nowy = dp[i - 1][j - 1] - (j - 1);
if(belong(nowx, nowy, q[i].lx, q[i].ux, q[i].ly, q[i].uy))
{
dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
}
nowx = j, nowy = dp[i - 1][j] - j;
if(belong(nowx, nowy, q[i].lx, q[i].ux, q[i].ly, q[i].uy))
{
dp[i][j] = max(dp[i][j], dp[i - 1][j] + 1);
}
}
}
//for(int i = 0; i <= n; i++)
// for(int j = 0; j <= n; j++)
// cout << dp[i][j] << " \n"[j == n];
cout << *max_element(dp[n].begin(), dp[n].end()) << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
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: 36ms
memory: 199028kb
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: -100
Wrong Answer
time: 39ms
memory: 199012kb
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:
1
result:
wrong answer 1st lines differ - expected: '5000', found: '1'