QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#745331 | #8780. Training, Round 2 | orz_z | TL | 3881ms | 217100kb | C++14 | 5.7kb | 2024-11-14 09:13:11 | 2024-11-14 09:13:11 |
Judging History
answer
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
//#pragma GCC optimize("Ofast,fast-math")
//#pragma GCC target("avx,avx2")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;
#define F(i, a, b) for(int i = a; i <= (b); ++i)
#define F2(i, a, b) for(int i = a; i < (b); ++i)
#define dF(i, a, b) for(int i = a; i >= (b); --i)
template<typename T> void debug(string s, T x) {
cerr << "[" << s << "] = [" << x << "]\n";
}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {
for (int i = 0, b = 0; i < (int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++;
else if (s[i] == ')' || s[i] == '}') b--;
else if (s[i] == ',' && b == 0) {
cerr << "[" << s.substr(0, i) << "] = [" << x << "] | ";
debug(s.substr(s.find_first_not_of(' ', i + 1)), args...);
break;
}
}
#ifdef ONLINE_JUDGE
#define Debug(...)
#else
#define Debug(...) debug(#__VA_ARGS__, __VA_ARGS__)
#endif
#define pb push_back
#define fi first
#define se second
#define Mry fprintf(stderr, "%.3lf MB\n", (&Med - &Mbe) / 1048576.0)
#define Try cerr << 1e3 * clock() / CLOCKS_PER_SEC << " ms\n";
typedef long long ll;
// namespace Fread {const int SIZE = 1 << 17; char buf[SIZE], *S, *T; inline char getchar() {if (S == T) {T = (S = buf) + fread(buf, 1, SIZE, stdin); if (S == T) return '\n';} return *S++;}}
// namespace Fwrite {const int SIZE = 1 << 17; char buf[SIZE], *S = buf, *T = buf + SIZE; inline void flush() {fwrite(buf, 1, S - buf, stdout), S = buf;} inline void putchar(char c) {*S++ = c;if (S == T) flush();} struct NTR {~NTR() {flush();}} ztr;}
// #ifdef ONLINE_JUDGE
// #define getchar Fread::getchar
// #define putchar Fwrite::putchar
// #endif
inline int ri() {
int x = 0;
bool t = 0;
char c = getchar();
while (c < '0' || c > '9') t |= c == '-', c = getchar();
while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
return t ? -x : x;
}
inline void wi(int x) {
if (x < 0) {
putchar('-'), x = -x;
}
if (x > 9) wi(x / 10);
putchar(x % 10 + 48);
}
inline void wi(int x, char s) {
wi(x), putchar(s);
}
bool Mbe;
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3f;
const int _ = 2e5 + 5;
int n, f[5005][5005];
pii a[_], b[_];
set<int> g[_];
bool Med;
signed main() {
// Mry;
// freopen("1.txt", "r", stdin);
n = ri();
int s1 = ri(), s2 = ri();
F(i, 1, n) a[i].fi = ri(), a[i].se = ri(), b[i].fi = ri(), b[i].se = ri();
F(i, 0, n + 1) F(j, 0, n + 1) f[i][j] = -infll;
f[0][0] = 0;
g[0].insert(0);
F(i, 1, n) {
set<pii> cz;
F(j, 0, i - 1) {
// f[j][i] = max(f[j][i], f[j][i - 1]);
// if(f[j][i - 1] == -infll) continue;
if(j + s1 >= a[i].fi && j + s1 <= a[i].se) {
int l = b[i].fi - s2 + j, r = b[i].se - s2 + j;
if(l > r || g[j].empty()) continue;
auto P = g[j].lower_bound(l);
while(P != g[j].end() && *P >= l && *P <= r) {
cz.insert({j, (*P) + 1});
cz.insert({j + 1, (*P) + 1});
// Debug("1ha", j, *P + 1);
P++;
}
// P = g[j + 1].lower_bound(l);
// if(P != g[j + 1].end() && *P >= l && *P <= r) {
// int R;
// if(next(P) == g[j + 1].end()) R = r;
// else R = (*next(P)) - 1;
// for(auto z = g[j].lower_bound(*P); z != g[j].end() && (*z <= R); z++) {
// cz.insert({j + 1, *z + 1});
// }
// if(g[j].lower_bound(*P) != g[j].end()) {
// cz.insert({j + 1, *P + 1});
// }
// P++;
// }
// int p = *prev(g[j].upper_bound(r));
// if(p >= l && p <= r) {
// bool flg = 0;
// for(pii v : cz) if((v.fi == j && v.se == p + 1) || g[v.fi].find(v.se) != g[v.fi].end()) {
// flg = 1;
// break;
// }
// Debug(j, p + 1, flg);
// cz.insert({j, p + 1});
// cz.insert({j + 1, p + 1});
// f[j][i] = max(f[j][i], p + 1);
// f[j + 1][i] = max(f[j + 1][i], p + 1);
// }
}
// assert(f[j][i] >= f[j][i - 1]);
}
for(pii v : cz) g[v.fi].insert(v.se);
// F(j, 0, i) g[j].insert(f[j][i]);
Debug(i, f[0][i], f[1][i], f[2][i]);
}
int ans = -infll;
F(i, 0, n) if(!g[i].empty()) ans = max(ans, *prev(g[i].end()));
cout << ans <<'\n';
// Try;
return 0;
}
/*
17 716580777 76836128
716580777 716580777 76836128 76836128
716580777 716580777 76836129 76836129
716580777 716580777 76836130 76836130
716580777 716580777 76836131 76836131
716580778 716580778 76836131 76836131
716580779 716580779 76836131 76836131
716580780 716580780 76836131 76836131
716580778 716580778 76836128 76836128
716580778 716580778 76836129 76836129
716580779 716580779 76836129 76836129
716580780 716580780 76836129 76836129
716580780 716580780 76836130 76836130
716580780 716580780 76836131 76836131
716580780 716580780 76836132 76836132
716580781 716580781 76836132 76836132
716580781 716580781 76836133 76836133
716580781 716580781 76836134 76836134
6 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
1007 716580777 76836128
716580777 716580777 76836128 76836128
716580777 716580777 76836129 76836129
716580777 716580777 76836130 76836130
716580777 716580777 76836131 76836131
716580778 716580778 76836131 76836131
716580779 716580779 76836131 76836131
716580780 716580780 76836131 76836131
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 17544kb
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: 20ms
memory: 213220kb
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: 15ms
memory: 213212kb
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: 0
Accepted
time: 27ms
memory: 213164kb
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:
4994
result:
ok single line: '4994'
Test #5:
score: 0
Accepted
time: 19ms
memory: 213396kb
input:
5000 716580777 76836128 716580777 716580777 76836128 76836128 716580777 716580777 76836129 76836129 716580777 716580777 76836130 76836130 716580777 716580777 76836131 76836131 716580778 716580778 76836131 76836131 716580779 716580779 76836131 76836131 716580780 716580780 76836131 76836131 716580778 ...
output:
4994
result:
ok single line: '4994'
Test #6:
score: 0
Accepted
time: 31ms
memory: 212628kb
input:
5000 774827789 700294316 774827790 774827791 700294315 700294317 774827789 774827790 700294317 700294318 774827789 774827790 700294316 700294316 774827787 774827787 700294315 700294316 774827789 774827791 700294315 700294318 774827787 774827789 700294317 700294318 774827787 774827788 700294314 70029...
output:
5
result:
ok single line: '5'
Test #7:
score: 0
Accepted
time: 31ms
memory: 212672kb
input:
5000 700294316 774827789 700294315 700294317 774827790 774827791 700294317 700294318 774827789 774827790 700294316 700294316 774827789 774827790 700294315 700294316 774827787 774827787 700294315 700294318 774827789 774827791 700294317 700294318 774827787 774827789 700294314 700294318 774827787 77482...
output:
5
result:
ok single line: '5'
Test #8:
score: 0
Accepted
time: 30ms
memory: 212748kb
input:
5000 256309650 340081224 256309647 256309649 340081224 340081227 256309645 256309650 340081226 340081229 256309652 256309652 340081219 340081220 256309645 256309655 340081222 340081226 256309646 256309648 340081221 340081225 256309651 256309654 340081219 340081221 256309651 256309653 340081219 34008...
output:
11
result:
ok single line: '11'
Test #9:
score: 0
Accepted
time: 24ms
memory: 212756kb
input:
5000 340081224 256309650 340081224 340081227 256309647 256309649 340081226 340081229 256309645 256309650 340081219 340081220 256309652 256309652 340081222 340081226 256309645 256309655 340081221 340081225 256309646 256309648 340081219 340081221 256309651 256309654 340081219 340081226 256309651 25630...
output:
11
result:
ok single line: '11'
Test #10:
score: 0
Accepted
time: 32ms
memory: 212976kb
input:
5000 490966735 218892297 490966732 490966733 218892303 218892305 490966741 490966741 218892298 218892301 490966733 490966735 218892291 218892297 490966729 490966734 218892296 218892301 490966742 490966745 218892287 218892303 490966726 490966738 218892301 218892305 490966726 490966730 218892292 21889...
output:
21
result:
ok single line: '21'
Test #11:
score: 0
Accepted
time: 36ms
memory: 215024kb
input:
5000 218892297 490966735 218892303 218892305 490966732 490966733 218892298 218892301 490966741 490966741 218892291 218892297 490966733 490966735 218892296 218892301 490966729 490966734 218892287 218892303 490966742 490966745 218892301 218892305 490966726 490966738 218892292 218892300 490966726 49096...
output:
21
result:
ok single line: '21'
Test #12:
score: 0
Accepted
time: 69ms
memory: 212684kb
input:
5000 619930859 159808007 619930853 619930854 159808007 159808017 619930840 619930856 159808013 159808025 619930848 619930864 159807995 159808009 619930844 619930847 159808008 159808022 619930848 619930856 159807995 159808001 619930850 619930852 159808020 159808022 619930853 619930871 159807992 15980...
output:
41
result:
ok single line: '41'
Test #13:
score: 0
Accepted
time: 66ms
memory: 212748kb
input:
5000 159808007 619930859 159808007 159808017 619930853 619930854 159808013 159808025 619930840 619930856 159807995 159808009 619930848 619930864 159808008 159808022 619930844 619930847 159807995 159808001 619930848 619930856 159808020 159808022 619930850 619930852 159807992 159808024 619930853 61993...
output:
41
result:
ok single line: '41'
Test #14:
score: 0
Accepted
time: 260ms
memory: 212964kb
input:
5000 974187020 583788009 974186973 974187017 583788001 583788028 974187035 974187052 583788011 583788027 974187016 974187037 583787973 583787981 974187036 974187046 583788012 583788028 974187046 974187066 583788042 583788056 974186994 974187016 583788013 583788044 974186986 974186989 583787969 58378...
output:
100
result:
ok single line: '100'
Test #15:
score: 0
Accepted
time: 257ms
memory: 213260kb
input:
5000 583788009 974187020 583788001 583788028 974186973 974187017 583788011 583788027 974187035 974187052 583787973 583787981 974187016 974187037 583788012 583788028 974187036 974187046 583788042 583788056 974187046 974187066 583788013 583788044 974186994 974187016 583787969 583787994 974186986 97418...
output:
100
result:
ok single line: '100'
Test #16:
score: 0
Accepted
time: 1033ms
memory: 214008kb
input:
5000 684153868 455686026 684153781 684153927 455685991 455686049 684153899 684153921 455686036 455686037 684153784 684153959 455685984 455686049 684153967 684153968 455685927 455686014 684153795 684153963 455685926 455686026 684153787 684153846 455686084 455686105 684153817 684153870 455685928 45568...
output:
195
result:
ok single line: '195'
Test #17:
score: 0
Accepted
time: 1019ms
memory: 213784kb
input:
5000 455686026 684153868 455685991 455686049 684153781 684153927 455686036 455686037 684153899 684153921 455685984 455686049 684153784 684153959 455685927 455686014 684153967 684153968 455685926 455686026 684153795 684153963 455686084 455686105 684153787 684153846 455685928 455686002 684153817 68415...
output:
195
result:
ok single line: '195'
Test #18:
score: 0
Accepted
time: 3861ms
memory: 217096kb
input:
5000 999613320 323981653 999613235 999613461 323981523 323981741 999613292 999613510 323981543 323981775 999613390 999613409 323981669 323981831 999613416 999613497 323981638 323981846 999613234 999613269 323981627 323981669 999613414 999613489 323981453 323981526 999613174 999613358 323981489 32398...
output:
366
result:
ok single line: '366'
Test #19:
score: 0
Accepted
time: 3881ms
memory: 217100kb
input:
5000 323981653 999613320 323981523 323981741 999613235 999613461 323981543 323981775 999613292 999613510 323981669 323981831 999613390 999613409 323981638 323981846 999613416 999613497 323981627 323981669 999613234 999613269 323981453 323981526 999613414 999613489 323981489 323981828 999613174 99961...
output:
366
result:
ok single line: '366'
Test #20:
score: -100
Time Limit Exceeded
input:
5000 555184387 498929492 555184771 555184789 498929431 498929765 555184225 555184302 498929308 498929410 555184166 555184206 498929155 498929424 555183905 555184344 498929667 498929688 555184514 555184517 498929218 498929639 555184130 555184438 498929083 498929692 555184520 555184681 498929153 49892...