QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#745382 | #8780. Training, Round 2 | orz_z | WA | 0ms | 16056kb | C++14 | 5.0kb | 2024-11-14 09:34:41 | 2024-11-14 09:34:42 |
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;
pii a[_], b[_];
map<int, int> g[_];
int fa[5005][5005];
int find(int rt, int x) {
return fa[rt][x] == x ? x : fa[rt][x] = find(rt, fa[rt][x]);
}
void add(int rt, int x) {
auto p = g[rt].lower_bound(x);
if(p != g[rt].end() && p->fi == x) return;
g[rt].insert({x, 1});
fa[rt][find(rt, x)] = find(rt, x + 1);
}
bool Med;
signed main() {
// Mry;
// freopen("1.txt", "r", stdin);
n = ri();
F(i, 0, n + 1) F(j, 0, n + 1) fa[i][j] = j;
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();
add(0, 0);
F(i, 1, n) {
vector<pii> cz;
F(j, 0, i - 1) {
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;
int P = find(j, l) - 1;
int ti = 0;
while(g[j][P] && P >= l && P <= r) {
cz.pb({j, (P) + 1});
cz.pb({j + 1, (P) + 1});
int nxt = min(find(j + 1, (P) + 1), find(j, (P) + 1)) - 1;
int lst = P;
ti++;
if(ti >= 5500) {
assert(0);
}
assert(g[j][nxt]);
P = g[j][nxt];
if(P == lst) P++;
}
}
}
for(pii v : cz) add(v.fi, v.se);
}
int ans = -inf;
F(i, 0, n) if(!g[i].empty()) ans = max(ans, prev(g[i].end())->fi);
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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 16056kb
input:
3 0 0 0 1 0 1 1 1 0 1 1 1 1 1
output:
2
result:
wrong answer 1st lines differ - expected: '3', found: '2'