QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740540 | #8780. Training, Round 2 | actor | WA | 36ms | 11664kb | C++14 | 1.7kb | 2024-11-13 10:22:00 | 2024-11-13 10:22:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for (int i = (l); i <= (r); i++)
#define per(i,r,l) for (int i = (r); i >= (l); i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define maxn(a, b) a = max(a, b)
#define minn(a, b) a = min(a, b)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod = 998244353;
mt19937 gen(random_device{}());
ll rp(ll a,ll b) {ll res=1%mod;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 5043;
int n, s, t;
int xl[N], xr[N], yl[N], yr[N];
int dp[N][N];
bitset<N> f[N], pre[N], suf[N];
int main() {
scanf("%d%d%d", &n, &s, &t);
rep(i,1,n) {
scanf("%d%d%d%d", &xl[i], &xr[i], &yl[i], &yr[i]);
xl[i] -= s, xr[i] -= s;
yl[i] -= t, yr[i] -= t;
}
pre[0].set(0);
rep(i,1,n) {
pre[i]=pre[i-1];
pre[i].set(i);
}
suf[n].set(n);
per(i,n-1,0) {
suf[i]=suf[i+1];
suf[i].set(i);
}
f[0].set(0);
rep(i,1,n) {
per(j,i,0) {
if (xl[i] <= j && j <= xr[i]) {
bitset<N> tmp=f[j];
int l = yl[i], r = yr[i];
if (l) tmp = tmp | pre[l - 1];
if (r < i) tmp = tmp | suf[r + 1];
f[j] = f[j]|(tmp<<1);
f[j+1] = f[j+1]|tmp;
}
}
}
int ans = 0;
rep(i,0,n) rep(j,0,n) if (f[i][j]) {
maxn(ans, n - (i + j));
}
printf("%d\n", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7952kb
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: 29ms
memory: 11664kb
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: 32ms
memory: 11564kb
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: 36ms
memory: 11104kb
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:
5000
result:
wrong answer 1st lines differ - expected: '4994', found: '5000'