QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#465731 | #8780. Training, Round 2 | Geothermal | WA | 59ms | 199140kb | C++20 | 2.3kb | 2024-07-07 06:53:29 | 2024-07-07 06:53:30 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
const char nl = '\n';
int bst1[5002][5002], bst2[5002][5002];
void solve() {
int N, B1, B2; cin >> N >> B1 >> B2;
int X1[N], X2[N], Y1[N], Y2[N];
F0R(i, N) cin >> X1[i] >> X2[i] >> Y1[i] >> Y2[i];
F0R(i, N) {
X1[i] -= B1; X2[i] -= B1;
Y1[i] -= B1; Y2[i] -= B2;
}
bst1[0][0] = 0;
bst2[0][0] = 0;
FOR(i, 1, N+1) bst1[0][i] = -1000000007;
FOR(i, 1, N+1) bst2[0][i] = -1000000007;
F0R(i, N) {
F0R(j, N+1) {
bst1[i+1][j] = bst1[i][j];
bst2[i+1][j] = bst2[i][j];
}
F0R(j, N+1) {
if (j >= X1[i] && j <= X2[i] && bst1[i][j] >= Y1[i] && bst1[i][j] <= Y2[i]) {
bst1[i+1][j] = max(bst1[i+1][j],bst1[i][j]+1);
bst1[i+1][j+1] = max(bst1[i+1][j+1], bst1[i][j]);
bst2[i+1][bst1[i][j]] = max(bst2[i+1][bst1[i][j]], j+1);
bst2[i+1][bst1[i][j]+1] = max(bst2[i+1][bst1[i][j]+1], j);
}
if (j >= Y1[i] && j <= Y2[i] && bst2[i][j] >= X1[i] && bst2[i][j] <= X2[i]) {
bst2[i+1][j] = max(bst2[i+1][j],bst2[i][j]+1);
bst2[i+1][j+1] = max(bst2[i+1][j+1], bst2[i][j]);
bst1[i+1][bst2[i][j]] = max(bst1[i+1][bst2[i][j]], j+1);
bst1[i+1][bst2[i][j]+1] = max(bst1[i+1][bst2[i][j]+1], j);
}
}
}
int ans = 0;
F0R(i, N+1) {
ans = max(ans, bst1[N][i] + i);
ans = max(ans, bst2[N][i] + i);
}
cout << ans << nl;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5572kb
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: 59ms
memory: 199140kb
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'