2026 的第一场雪
今日清晨,恍然发现窗外飘雪。
穿衣,洗漱,出门。
上学路上的车窗外,微微亮的天空下,路灯照耀旁,好像有着她的身影……
那么甜,那么深沉,在那漫天轻柔细腻的飘雪中……
但我不得不离开,由于各种原因——
何时才能再相见。
……
原来都是泡影吗——我根本没有 npy!我有所谓白月光状物吗?不能连这个都没有吧……是不敢接受自己内心深处的想法吗,是不敢于面对青春的真挚情感吗……
或者是她还没莅临我的世界——
LEWISAK 还是太成功了。
其实这是比赛总结。
CSP-S2026模拟赛 1
| T1 | T2 | T3 | T4 |
|---|---|---|---|
| 100 AC | 100 AC | 10 WA | 100 AC |
总分:310;排名:2/13。
说白了,没挂。T1 写个筛法做完了,T2 就是个 Kurskal 重构树板子题。
T1 质因数分解
写个筛法求质因子没了。复杂度 \(O(n\log V)\)。
点击查看代码
#include <bits/stdc++.h>
#define il inline
#define int long long
using namespace std;
bool Beg;
namespace Zctf1088 {
const int N = 1e6 + 10;
int n;
int f[N], p[N], tot, mn[N];
il void init() {
for (int i = 2; i <= n; i++) {
if (!f[i]) {
p[++tot] = i;
mn[i] = tot;
}
for (int j = 1; j <= tot; j++) {
if (i * p[j] > n) break;
f[i * p[j]] = 1;
mn[i * p[j]] = j;
if (i % p[j] == 0) break;
}
}
}
int t[N];
signed main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
init();
for (int i = 1; i <= n; i++) {
int x = i;
while (x > 1) {
t[mn[x]]++;
x /= p[mn[x]];
}
}
cout << n << "!=";
int fl = 0;
for (int i = 1; i <= tot; i++) {
if (!t[i]) continue;
if (fl) cout << "*";
fl = 1;
cout << p[i];
if (t[i] > 1) cout << "^" << t[i];
}
cout << "\n";
return 0;
}}
bool End;
il void Usd() {cerr << "\nUse: " << (&Beg - &End) / 1024.0 / 1024.0 << "MB " << (double)clock() * 1000.0 / CLOCKS_PER_SEC << "ms\n";}
signed main() {
Zctf1088::main();
Usd();
return 0;
}
T2 桥梁建造师
Kurskal 重构树板子题。不会的去这里。
点击查看代码
#include <bits/stdc++.h>
#define il inline
using namespace std;
bool Beg;
namespace Zctf1088 {
namespace IO {
const int bufsz = 1 << 20;
char ibuf[bufsz], *p1 = ibuf, *p2 = ibuf;
#define getchar() (p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, bufsz, stdin), p1 == p2) ? EOF : *p1++)
il int read() {
int x = 0; char ch = getchar(); bool t = 0;
while (ch < '0' || ch > '9') {t ^= ch == '-'; ch = getchar();}
while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();}
return t ? -x : x;
}
char obuf[bufsz], *p3 = obuf, stk[50];
#define flush() (fwrite(obuf, 1, p3 - obuf, stdout), p3 = obuf)
#define putchar(ch) (p3 == obuf + bufsz && flush(), *p3++ = (ch))
il void write(int x, bool t = 0) {
int top = 0;
x < 0 ? putchar('-'), x = -x : 0;
do {stk[++top] = x % 10 | 48; x /= 10;} while(x);
while (top) putchar(stk[top--]);
t ? putchar(' ') : putchar('\n');
}
struct FL {
~FL() {flush();}
} fl;
}
using IO::read; using IO::write;
const int N = 1e5 + 10, M = 20;
int n, m;
vector<int> G[N];
struct node {
int x, y, w;
il bool operator < (const node & cmp) const {
return w > cmp.w;
}
} e[N];
int fa[N], rt[N], val[N];
il int getfa(int x) {
return x == fa[x] ? x : fa[x] = getfa(fa[x]);
}
int dfn[N], id[N << 1], mn[N << 1][M], Log2[N << 1], tim;
il void dfs(int x) {
id[++tim] = x;
dfn[x] = tim;
for (int y : G[x]) {
dfs(y);
id[++tim] = x;
}
}
il void init() {
for (int i = 2; i <= tim; i++) Log2[i] = Log2[i / 2] + 1;
for (int i = 1; i <= tim; i++) mn[i][0] = dfn[id[i]];
for (int j = 1; j <= Log2[tim]; j++) {
for (int i = 1; i + (1 << j) - 1 <= tim; i++)
mn[i][j] = min(mn[i][j - 1], mn[i + (1 << (j - 1))][j - 1]);
}
}
il int getlca(int x, int y) {
if (dfn[x] > dfn[y]) swap(x, y);
int s = Log2[dfn[y] - dfn[x] + 1];
return id[min(mn[dfn[x]][s], mn[dfn[y] - (1 << s) + 1][s])];
}
signed main() {
n = read(), m = read();
for (int i = 1; i <= m; i++) {
int x = read(), y = read(), w = read();
e[i] = {x, y, w};
}
sort(e + 1, e + 1 + m);
int tot = n;
for (int i = 1; i <= n; i++) fa[i] = rt[i] = i;
for (int i = 1; i <= m; i++) {
int x = getfa(e[i].x), y = getfa(e[i].y);
if (x != y) {
fa[y] = x;
val[++tot] = e[i].w;
G[tot].push_back(rt[x]);
G[tot].push_back(rt[y]);
rt[x] = rt[y] = tot;
}
}
for (int i = tot; i >= 1; i--) {
if (!dfn[i]) dfs(i);
}
init();
int qq = read();
while (qq--) {
int x = read(), y = read();
if (getfa(x) != getfa(y)) write(-1);
else write(val[getlca(x, y)]);
}
return 0;
}}
bool End;
il void Usd() {cerr << "\nUse: " << (&Beg - &End) / 1024.0 / 1024.0 << "MB " << (double)clock() * 1000.0 / CLOCKS_PER_SEC << "ms\n";}
signed main() {
Zctf1088::main();
Usd();
return 0;
}
T3 产品加工
考虑两个工序之间互不影响,那就把他们分开处理。考虑处理出每个零件第一、二个机器的最小用时 \(f_i\),\(g_i\)。
然后就没了,不知道赛时在吃什么大粪。可能是没想到上面这些。
然后直接用优先队列贪心维护,分别处理出 \(f_i\) 和 \(g_i\)。对,就是你想的那么贪。
然后合并,考虑两头合并,就是一个升序排一个降序排,答案即为 \(\max\{f_i+g_i\}\)。
点击查看代码
#include <bits/stdc++.h>
#define il inline
#define int long long
using namespace std;
bool Beg;
namespace Zctf1088 {
namespace IO {
const int bufsz = 1 << 20;
char ibuf[bufsz], *p1 = ibuf, *p2 = ibuf;
#define getchar() (p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, bufsz, stdin), p1 == p2) ? EOF : *p1++)
il int read() {
int x = 0; char ch = getchar(); bool t = 0;
while (ch < '0' || ch > '9') {t ^= ch == '-'; ch = getchar();}
while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();}
return t ? -x : x;
}
char obuf[bufsz], *p3 = obuf, stk[50];
#define flush() (fwrite(obuf, 1, p3 - obuf, stdout), p3 = obuf)
#define putchar(ch) (p3 == obuf + bufsz && flush(), *p3++ = (ch))
il void write(int x, bool t = 0) {
int top = 0;
x < 0 ? putchar('-'), x = -x : 0;
do {stk[++top] = x % 10 | 48; x /= 10;} while(x);
while (top) putchar(stk[top--]);
t ? putchar(' ') : putchar('\n');
}
struct FL {
~FL() {flush();}
} fl;
}
using IO::read; using IO::write;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e6 + 10;
int qq, n, m, a[N], b[N];
struct node {
int tim, id;
il bool operator < (const node & c) const {
return tim > c.tim;
}
};
priority_queue<node> q;
int f[N], g[N];
signed main() {
qq = read(), n = read(), m = read();
for (int i = 1; i <= n; i++) a[i] = read();
for (int i = 1; i <= m; i++) b[i] = read();
for (int i = 1; i <= n; i++) q.push({a[i], i});
for (int i = 1; i <= qq; i++) {
node t = q.top(); q.pop();
f[i] = t.tim;
q.push({t.tim + a[t.id], t.id});
}
while (!q.empty()) q.pop();
for (int i = 1; i <= m; i++) q.push({b[i], i});
for (int i = 1; i <= qq; i++) {
node t = q.top(); q.pop();
g[i] = t.tim;
q.push({t.tim + b[t.id], t.id});
}
int ans = 0;
for (int i = 1; i <= qq; i++)
ans = max(ans, f[i] + g[qq - i + 1]);
write(ans);
return 0;
}}
bool End;
il void Usd() {cerr << "\nUse: " << (&Beg - &End) / 1024.0 / 1024.0 << "MB " << (double)clock() * 1000.0 / CLOCKS_PER_SEC << "ms\n";}
signed main() {
Zctf1088::main();
Usd();
return 0;
}
T4 优美的序列
求 \(\oplus_{t=i}^j a_t =k\) 的 \((i,j)\) 数量,作前缀和,即 \(s_{i-1}\oplus s_j=k\)。
考虑拆位,即求形如 \(a \oplus b =k\)。
考虑枚举前 \(i-1\) 位相同,第 \(i\) 位上 \((a\oplus b)\) 为 \(1\) 且 \(k\) 的第 \(i\) 位为 \(0\)。显然是不重不漏的。
然后随便搞个桶统计一遍就行了。
复杂度 \(O(n \log V)\)。
点击查看代码
#include <bits/stdc++.h>
#define il inline
#define int long long
using namespace std;
bool Beg;
namespace Zctf1088 {
namespace IO {
const int bufsz = 1 << 20;
char ibuf[bufsz], *p1 = ibuf, *p2 = ibuf;
#define getchar() (p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, bufsz, stdin), p1 == p2) ? EOF : *p1++)
il int read() {
int x = 0; char ch = getchar(); bool t = 0;
while (ch < '0' || ch > '9') {t ^= ch == '-'; ch = getchar();}
while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();}
return t ? -x : x;
}
char obuf[bufsz], *p3 = obuf, stk[50];
#define flush() (fwrite(obuf, 1, p3 - obuf, stdout), p3 = obuf)
#define putchar(ch) (p3 == obuf + bufsz && flush(), *p3++ = (ch))
il void write(int x, bool t = 0) {
int top = 0;
x < 0 ? putchar('-'), x = -x : 0;
do {stk[++top] = x % 10 | 48; x /= 10;} while(x);
while (top) putchar(stk[top--]);
t ? putchar(' ') : putchar('\n');
}
struct FL {
~FL() {flush();}
} fl;
}
using IO::read; using IO::write;
const int N = 1e5 + 10;
int n, kk, a[N], s[N];
unordered_map<int, int> mp;
signed main() {
n = read(), kk = read();
for (int i = 1; i <= n; i++) a[i] = read();
for (int i = 1; i <= n; i++) s[i] = s[i - 1] ^ a[i];
int res = 0, ms = 0;
for (int i = 31; i >= 0; i--) {
ms |= (1ll << i);
if ((kk >> i) & 1) continue;
mp.clear();
for (int j = 0; j <= n; j++) {
res += mp[((kk & ms) | (1ll << i)) ^ (s[j] & ms)];
mp[s[j] & ms]++;
}
}
mp.clear();
for (int j = 0; j <= n; j++) {
res += mp[kk ^ s[j]];
mp[s[j]]++;
}
write(res);
return 0;
}}
bool End;
il void Usd() {cerr << "\nUse: " << (&Beg - &End) / 1024.0 / 1024.0 << "MB " << (double)clock() * 1000.0 / CLOCKS_PER_SEC << "ms\n";}
signed main() {
Zctf1088::main();
Usd();
return 0;
}

浙公网安备 33010602011771号