NOIP2023邮寄
前情提要:
\texttt{CSP} 考前不给摸鱼,导致我只有250 。
加入拜喵喵叫
嘿嘿,这次摸鱼了,感觉至少没有很惨。
晚上跟 dhf 说明天最长代码肯定
给同步赛的学弟留了一个名为
坐我位置上的学弟看起来好像体型上碾压我(?
前一天没有睡好,布衾冷似铁,舍友的闹钟六点出头就响了,外面还有 GFM 的超大声起床音乐,为了
忘记几点了,进考场,感觉好像安检好松啊。
忘记几点了,打开虚拟机,发现虚拟机好卡,打开
忘记几点了,关掉虚拟机的我打开 T1,写了个 Trie 树?我也不知道我在干啥,发现炸空间了,然后赶紧写了一个二分哈希,
忘记几点了,大概九点?开了 T2,一眼顶针,先处理出每个值由哪个的初值决定,最后去掉钦定的就剩下一个外向基环树森林,有矛盾就
然后顶针 T3 桌布初来,出去上了两趟厕所,吃了两颗糖,选择开 T4。
于是最梦幻的时刻,由于我猜它是线段树优化 dp,猜它要用线性空间,于是糊了一个
忘记几点了,发现只会
估分
T4 在小图灵上 wa,喜提
芝士我的 T4 代码,大佬帮帮:
//terrible! it passed all samples
//i hope it can get 100pts
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxm = 1e5 + 10;
const int maxn = 3 * maxm;
class SegTree {//modify range add, query range max
public:
ll tr[maxn << 2], lazy[maxn << 2];
void __getmax(ll& x, ll y) {
if(x < y) x = y;
}
void __update(int k) {
tr[k] = max(tr[k << 1], tr[k << 1 | 1]);
}
void __push(int k) {
if(!lazy[k]) return;
tr[k << 1] += lazy[k];
tr[k << 1 | 1] += lazy[k];
lazy[k << 1] += lazy[k];
lazy[k << 1 | 1] += lazy[k];
lazy[k] = 0;
return;
}
void modify(int k, int l, int r, int L, int R, ll val) {
if(L <= l && r <= R) {
tr[k] += val;
lazy[k] += val;
return;
}
__push(k);
int mid = (l + r) >> 1;
if(L <= mid) modify(k << 1, l, mid, L, R, val);
if(R > mid) modify(k << 1 | 1, mid + 1, r, L, R, val);
__update(k);
}
ll query(int k, int l, int r, int L, int R) {
if(L <= l && r <= R) return tr[k];
__push(k);
int mid = (l + r) >> 1;
ll res = INT64_MIN;
if(L <= mid) __getmax(res, query(k << 1, l, mid, L, R));
if(R > mid) __getmax(res, query(k << 1 | 1, mid + 1, r, L, R));
return res;
}
void build(int k, int l, int r, const vector<int>& num, int d) {
lazy[k] = 0;
if(l == r) {
tr[k] = (ll)d * num[l - 1];
return;
}
int mid = (l + r) >> 1;
build(k << 1, l, mid, num, d);
build(k << 1 | 1, mid + 1, r, num, d);
__update(k);
}
}sgt;
int n, m, k, d;
class Rew {
public:
int l, r, w;
Rew() = default;
Rew(int l, int r, int w) : l(l), r(r), w(w) {}
};
vector<Rew> q;
vector<int> num;
ll ans;
void Solve() {
q.clear();
num.clear();
cin >> n >> m >> k >> d;
for(int i = 1; i <= m; i++) {
int x, y, v;
cin >> x >> y >> v;
if(y > k) continue;
q.emplace_back(x - y + 1, x, v);
int l = x - y + 1;
int r = x;
num.emplace_back(max(1, r - k + 1));
num.emplace_back(l);
if(r + 2 <= n) num.emplace_back(r + 2);
}
num.emplace_back(n);
sort(q.begin(), q.end(), [](Rew a, Rew b) {
if(a.r != b.r) return a.r < b.r;
return a.l < b.l;
});
sort(num.begin(), num.end());
num.resize(unique(num.begin(), num.end()) - num.begin());
int lim = num.size();
sgt.build(1, 1, lim, num, d);
ans = 0;
for(auto cur : q) {
int& l = cur.l, & r = cur.r, & w = cur.w;
int xl = lower_bound(num.begin(), num.end(), max(1, r - k + 1)) - num.begin() + 1;
int xr = lower_bound(num.begin(), num.end(), l) - num.begin() + 1;
sgt.modify(1, 1, lim, xl, xr, w);
ll res = sgt.query(1, 1, lim, xl, xr);
ll mx = res - (ll)d * (r + 1);
ans = max(ans, res - (ll)d * (r + 1));
if(r + 2 > n) continue;
xl = lower_bound(num.begin(), num.end(), r + 2) - num.begin() + 1;
xr = lower_bound(num.begin(), num.end(), n) - num.begin() + 1;
res = sgt.query(1, 1, lim, xr, xr) - (ll)d * n;
if(mx > res) sgt.modify(1, 1, lim, xl, xr, mx - res);
}
cout << ans << '\n';
}
int main() {
// freopen("run.in", "r", stdin);
// freopen("run.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int c, t;
cin >> c >> t;
while(t--) Solve();
}
?怎么特殊性质wa了,肯定是小土岭数据造挂了(确信)。
感觉冲省队有点难啊。。。
可能是我的最后一场考试了。
具体怎么样还要采访一下下周的我。
11.19 的我:你打算冲省队吗?
11.26 的我:……
对不起,受访者还没来。
先这样吧,好好享受一下 whk