历程

被暴打了

原因是钻进了 \(T4\) 的坑中。。。

先看完题,发现 \(T4\) 比较有意思,\(T2\) 没有想法

\(T3\) 挺容易,做法似乎很好想

\(T1\) 送分,十几分钟搞定

然后开 \(T4\),推了一下,明白题目需要我们干的事情

开码,发现修改与标记有些烦,然后标记打错了,一直调到 \(11\) 点

疯了!

还有 \(\text{45 min}\),只要忍痛弃了

看看 \(T3\),很好做,\(5 min\) 打完

有充满自信,放弃 \(T2\) 部分分,继续调 \(T4\)

但始终没有意识到一处标记的问题

导致比赛结束被暴打(更重要的是,暴力每题普遍 \(80,90pts\) !!神仙数据。。。)

\(\text{T1 1782. Travel}\)

这不 \(Floyd\) 预处理后分层最短路 \(spfa\) 啊!

正好复习最短路模板

$\text{Code}$

\(\text{Code}\)

  1. #include <cstdio>
  2. #include <queue>
  3. #include <cstring>
  4. #include <iostream>
  5. #define RE register
  6. using namespace std;
  7. const int N = 105, INF = 0x3f3f3f3f;
  8. int n, m, q, G[N][N], vis[N][N], bz[N][15], f[N][15];
  9. struct node{int x, k;};
  10. queue<node> Q;
  11. void SPFA()
  12. {
  13. memset(f, INF, sizeof f), Q.push(node{1, 0}), f[1][0] = 0, bz[1][0] = 1;
  14. while (!Q.empty())
  15. {
  16. node z = Q.front(); Q.pop();
  17. for(RE int i = 1; i <= n; i++)
  18. if (vis[z.x][i] && i ^ z.x)
  19. {
  20. int j = i, k = z.k, w = G[z.x][i];
  21. if (!vis[i][z.x]) w *= 2, ++k;
  22. if (k <= q && f[j][k] > f[z.x][z.k] + w)
  23. {
  24. f[j][k] = f[z.x][z.k] + w;
  25. if (!bz[j][k]) Q.push(node{j, k}), bz[j][k] = 1;
  26. }
  27. }
  28. bz[z.x][z.k] = 0;
  29. }
  30. }
  31. int main()
  32. {
  33. scanf("%d%d%d", &n, &m, &q), memset(G, INF, sizeof G);
  34. for(RE int i = 1, x, y, z; i <= m; i++)
  35. scanf("%d%d%d", &x, &y, &z), G[x][y] = min(G[x][y], z), vis[x][y] = 1;
  36. for(RE int k = 1; k <= n; k++)
  37. for(RE int i = 1; i <= n; i++)
  38. if (i ^ k)
  39. for(RE int j = 1; j <= n; j++)
  40. if (j ^ i && j ^ k)
  41. vis[i][j] = (vis[i][j] | (vis[i][k] && vis[k][j]));
  42. SPFA();
  43. int ans = INF;
  44. for(RE int i = 1; i <= q; i++) ans = min(ans, f[n][i]);
  45. if (ans == INF) ans = -1;
  46. printf("%d\n", ans);
  47. }

\(\text{T2 3337. wyl8899的TLE}\)

思考答案的产生

从 \(A\) 的首位, \(B\) 的某个位置开始,求 \(LCP\)

然后魔法地同时跳过一格(计入贡献),再求 \(LCP\)

答案取最大值即可

也就是说可以枚举 \(B\) 的开始位置,二分加哈希求 \(LCP\) 即可

思维真不高。。。

也算复习字符串基操吧

$\text{Code}$

\(\text{Code}\)

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <iostream>
  4. #define RE register
  5. #define IN inline
  6. using namespace std;
  7. typedef long long LL;
  8. const int N = 5e4 + 5, P1 = 1e9 + 7, P2 = 1e9 + 9, B = 29;
  9. char s1[N], s2[N];
  10. LL b1[N], b2[N];
  11. struct Hash{
  12. int n; LL p1[N], p2[N];
  13. IN void init(char *s)
  14. {
  15. n = strlen(s + 1);
  16. for(RE int i = 1; i <= n; i++)
  17. p1[i] = (p1[i - 1] * B + s[i] - 'a') % P1, p2[i] = (p2[i - 1] * B + s[i] - 'a') % P2;
  18. }
  19. IN int get1(int l, int r){return (p1[r] - p1[l - 1] * b1[r - l + 1] % P1 + P1) % P1;}
  20. IN int get2(int l, int r){return (p2[r] - p2[l - 1] * b2[r - l + 1] % P2 + P2) % P2;}
  21. }h1, h2;
  22. IN int lcp(int l1, int l2)
  23. {
  24. int l = 0, r = min(h1.n - l1 + 1, h2.n - l2 + 1), mid = l + r >> 1, res = 0;
  25. for(; l <= r; mid = l + r >> 1)
  26. if ((h1.get1(l1, l1 + mid - 1) == h2.get1(l2, l2 + mid - 1))
  27. && (h1.get2(l1, l1 + mid - 1) == h2.get2(l2, l2 + mid - 1))) res = mid, l = mid + 1;
  28. else r = mid - 1;
  29. return res;
  30. }
  31. int main()
  32. {
  33. b1[0] = b2[0] = 1;
  34. for(RE int i = 1; i <= N - 3; i++) b1[i] = b1[i - 1] * B % P1, b2[i] = b2[i - 1] * B % P2;
  35. scanf("%s%s", s1 + 1, s2 + 1), h1.init(s1), h2.init(s2);
  36. int ans = 0;
  37. for(RE int i = 1, len; i <= h2.n; i++)
  38. ans = max(ans, (len = lcp(1, i)) + lcp(len + 2, i + len + 1) + (len < h1.n && i + len - 1 < h2.n));
  39. printf("%d\n", ans);
  40. }

\(\text{T3 3338. 法法塔的奖励}\)

考虑一个点的答案,显然由子树符合条件的 \(dp\) 值转来

发现是维护子树的问题,所以树上启发式合并加树状数组做到 \(O(n\log^2 n)\) 或者线段树合并做到 \(O(n\log n)\)

当然是打前者啦,跟打暴力一样一样的

$\text{Code}$

\(\text{Code}\)

  1. #include <cstdio>
  2. #include <iostream>
  3. #define RE register
  4. #define IN inline
  5. using namespace std;
  6. const int N = 1e5 + 5;
  7. int n, fa[N], a[N], h[N], tot, c[N];
  8. int dfc, siz[N], dfn[N], rev[N], son[N], ans[N];
  9. struct edge{int to, nxt;}e[N];
  10. IN void add(int x, int y){e[++tot] = edge{y, h[x]}, h[x] = tot;}
  11. void dfs1(int x)
  12. {
  13. siz[x] = 1, dfn[x] = ++dfc, rev[dfc] = x;
  14. for(RE int i = h[x]; i; i = e[i].nxt)
  15. {
  16. int v = e[i].to;
  17. dfs1(v), siz[x] += siz[v];
  18. if (siz[v] > siz[son[x]]) son[x] = v;
  19. }
  20. }
  21. IN int lowbit(int x){return x & (-x);}
  22. IN void update(int x, int v){for(; x <= n; x += lowbit(x)) c[x] = max(c[x], v);}
  23. IN void clear(int x){for(; x <= n; x += lowbit(x)) c[x] = 0;}
  24. IN int query(int x)
  25. {
  26. int res = 0;
  27. for(; x; x -= lowbit(x)) res = max(res, c[x]);
  28. return res;
  29. }
  30. void dfs2(int x, int kp)
  31. {
  32. for(RE int i = h[x]; i; i = e[i].nxt)
  33. {
  34. int v = e[i].to;
  35. if (v == son[x]) continue;
  36. dfs2(v, 0);
  37. }
  38. if (son[x]) dfs2(son[x], 1);
  39. for(RE int i = h[x]; i; i = e[i].nxt)
  40. {
  41. int v = e[i].to;
  42. if (v == son[x]){update(a[son[x]], ans[son[x]]); continue;}
  43. for(RE int j = dfn[v]; j <= dfn[v] + siz[v] - 1; j++) update(a[rev[j]], ans[rev[j]]);
  44. }
  45. ans[x] = query(a[x]) + 1;
  46. if (!kp) for(RE int i = dfn[x] + 1; i <= dfn[x] + siz[x] - 1; i++) clear(a[rev[i]]);
  47. }
  48. int main()
  49. {
  50. scanf("%d", &n); int x; scanf("%d", &x);
  51. for(RE int i = 2; i <= n; i++) scanf("%d", &fa[i]), add(fa[i], i);
  52. for(RE int i = 1; i <= n; i++) scanf("%d", &a[i]);
  53. dfs1(1), dfs2(1, 1);
  54. for(RE int i = 1; i <= n; i++) printf("%d ", ans[i]);
  55. }

\(\text{T4 3339. wyl8899和法法塔的游戏}\)

很容易想到 \(nim\) 游戏的结论:异或和为零为先手必败态

那么先求异或和,需要第一步取完后留给对手必败态,即 \((a_r-x) \oplus \text{others} = 0\)

需 \(x=a_r-\text{others}\) 最大化,可持久化 \(Trie\) 即可

但是需要支持修改操作,所以考虑分块加 \(Trie\)

注意打标记时的细节

$\text{Code}$

\(\text{Code}\)

  1. #include <cstdio>
  2. #include <cmath>
  3. #include <iostream>
  4. #define IN inline
  5. #define RE register
  6. using namespace std;
  7. const int N = 1e5 + 5, B = 319;
  8. int n, m;
  9. struct DS{
  10. int pos[N], block, a[N], tag[B], tr[N * 20][2], size, sum[N * 20], rt[B];
  11. IN void init()
  12. {
  13. block = sqrt(n);
  14. for(RE int i = 1; i <= n; i++) pos[i] = (i - 1) / block + 1;
  15. }
  16. IN void update(int p, int x, int v)
  17. {
  18. if (!rt[p]) rt[p] = ++size;
  19. int u = rt[p];
  20. for(RE int i = 10; i >= 0; i--)
  21. {
  22. int ch = (x >> i) & 1;
  23. if (!tr[u][ch]) tr[u][ch] = ++size;
  24. sum[u = tr[u][ch]] += v;
  25. }
  26. }
  27. IN int query(int p, int v)
  28. {
  29. int u = rt[p], res = 0;
  30. for(RE int i = 10; i >= 0; i--)
  31. {
  32. int ch = (v >> i) & 1;
  33. if (sum[tr[u][ch]]) u = tr[u][ch];
  34. else if (sum[tr[u][ch ^ 1]]) u = tr[u][ch ^ 1], res |= (1 << i);
  35. }
  36. return res;
  37. }
  38. IN int get(int x){return a[x] ^ tag[pos[x]] ^ a[x + 1] ^ tag[pos[x + 1]];}
  39. IN void Modify(int r, int v)
  40. {
  41. int t = get(r), w = a[r] ^ (t - v) ^ tag[pos[r]] ^ a[r + 1] ^ tag[pos[r + 1]];
  42. for(RE int i = r; i >= (pos[r] - 1) * block + 1; i--)
  43. update(pos[r], a[i], -1), update(pos[r], a[i] ^= w, 1);
  44. for(RE int i = 1; i < pos[r]; i++) tag[i] ^= w;
  45. }
  46. IN int Query(int l, int r, int v)
  47. {
  48. int res = N;
  49. for(RE int i = l; i <= min(pos[l] * block, r); i++) res = min(res, a[i] ^ tag[pos[l]] ^ v);
  50. if (pos[l] ^ pos[r])
  51. for(RE int i = (pos[r] - 1) * block + 1; i <= r; i++) res = min(res, a[i] ^ tag[pos[r]] ^ v);
  52. for(RE int i = pos[l] + 1; i < pos[r]; i++) res = min(res, query(i, v ^ tag[i]));
  53. return res;
  54. }
  55. }T;
  56. int main()
  57. {
  58. scanf("%d", &n);
  59. for(RE int i = 1; i <= n; i++) scanf("%d", &T.a[i]);
  60. T.init();
  61. for(RE int i = n; i; i--) T.a[i] ^= T.a[i + 1], T.update(T.pos[i], T.a[i], 1);
  62. scanf("%d", &m);
  63. for(RE int i = 1, ed, L, R; i <= m; i++)
  64. {
  65. scanf("%d%d%d", &ed, &L, &R);
  66. int ans = T.get(ed) - T.Query(L, R, T.a[ed] ^ T.tag[T.pos[ed]]);
  67. if (ans <= 0) ans = -1;
  68. if (ans != -1) T.Modify(ed, ans);
  69. printf("%d\n", ans);
  70. }
  71. }

可见这套题挺简单的,但是考场要分配好时间,避免陷入一处坑很久导致意外或者“正常”死亡

JZOJ 2022.07.06【提高组A】模拟的更多相关文章

  1. 2018.12.30【NOIP提高组】模拟赛C组总结

    2018.12.30[NOIP提高组]模拟赛C组总结 今天成功回归开始做比赛 感觉十分良(zhōng)好(chà). 统计数字(count.pas/c/cpp) 字符串的展开(expand.pas/c ...

  2. 2018.12.08【NOIP提高组】模拟B组总结(未完成)

    2018.12.08[NOIP提高组]模拟B组总结 diyiti 保留道路 进化序列 B diyiti Description 给定n 根直的木棍,要从中选出6 根木棍,满足:能用这6 根木棍拼出一个 ...

  3. JZOJ 5185. 【NOIP2017提高组模拟6.30】tty's sequence

    5185. [NOIP2017提高组模拟6.30]tty's sequence (Standard IO) Time Limits: 1000 ms  Memory Limits: 262144 KB ...

  4. JZOJ 5196. 【NOIP2017提高组模拟7.3】B

    5196. [NOIP2017提高组模拟7.3]B Time Limits: 1000 ms  Memory Limits: 262144 KB  Detailed Limits   Goto Pro ...

  5. JZOJ 5197. 【NOIP2017提高组模拟7.3】C

    5197. [NOIP2017提高组模拟7.3]C Time Limits: 1000 ms  Memory Limits: 262144 KB  Detailed Limits   Goto Pro ...

  6. JZOJ 5195. 【NOIP2017提高组模拟7.3】A

    5195. [NOIP2017提高组模拟7.3]A Time Limits: 1000 ms  Memory Limits: 262144 KB  Detailed Limits   Goto Pro ...

  7. JZOJ 5184. 【NOIP2017提高组模拟6.29】Gift

    5184. [NOIP2017提高组模拟6.29]Gift (Standard IO) Time Limits: 1000 ms  Memory Limits: 262144 KB  Detailed ...

  8. Vigenère密码 2012年NOIP全国联赛提高组(字符串模拟)

    P1079 Vigenère 密码 题目描述 16 世纪法国外交家 Blaise de Vigenère 设计了一种多表密码加密算法――Vigenère 密 码.Vigenère 密码的加密解密算法简 ...

  9. 等价表达式 2005年NOIP全国联赛提高组(栈模拟)

    P1054 等价表达式 题目描述 明明进了中学之后,学到了代数表达式.有一天,他碰到一个很麻烦的选择题.这个题目的题干中首先给出了一个代数表达式,然后列出了若干选项,每个选项也是一个代数表达式,题目的 ...

  10. 2017.07.06【NOIP提高组】模拟赛B组

    Summary 今天比赛感觉题目很奇葩,都可以用许多简单方法来做,正确性都显然,当然也有点水,也就是说是考我们的数感和数学知识,而程序,只是代码的体现. 这次的时间安排感觉不错,因为很快就打完最后一道 ...

随机推荐

  1. Navicat mysql创建数据库、用户、授权、连接

    一.数据库的创建 调出命令窗口并创建数据库: create database itcast_oa default character set utf8;----创建数据库 二.数案件用户 create ...

  2. Java学习中实现的功能trick

    1.注册时,不用确认就可以知道用户名是否存在 技术:json+ajax 章节:javaweb->day22json&ajax 2.不常变化的导航栏.城市等信息存入数据库,通过redis做 ...

  3. Python中open()文件操作/OS目录操作

    File对象测试数据的读写与操作 #def open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, ...

  4. 过debugger的几种方法+案例

    受益匪浅 https://mp.weixin.qq.com/s/559so0RheeiQdA670J23yghttps://blog.csdn.net/weixin_43834227/article/ ...

  5. STL vector常用API

    1.容器:序列容器(时间决定).关联式容器(容器中的数据有一定规则) 2.迭代器:通过迭代器寻找.遍历容器中的数据 vetor的使用:数据遍历与输出 #define _CRT_SECURE_NO_WA ...

  6. c#5.0(.net 4.5之后)的 Async+await+Task的异步机制的调试笔记

    1.)无返回值的情况(异步也是基于线程). using System; using System.Collections.Generic; using System.Linq; using Syste ...

  7. 2021强网杯青少赛(qwtac)楼上大佬ddw WriteUp

    楼上大佬ddw战队WRITEUP 战队信息 战队名称:楼上大佬ddw 战队排名:24 解题情况 解题过程 01 签到 操作内容: 下载附件,打开运行拿到flag 如该题使用自己编写的脚本代码请详细写出 ...

  8. S2-016 CVE-2013-2251

    漏洞名称 S2-016(CVE-2013-2251) 通过操作前缀为"action:"/"redirect:"/"redirectAction:&qu ...

  9. python之路32 网络并发线程方法 线程池 协程

    多进程实现TCP服务端并发 服务端: import socket from multiprocessing import Process def get_server(): server = sock ...

  10. 【实战】yolov8 tensorrt模型加速部署

    [实战]yolov8 tensorrt模型加速部署 TensorRT-Alpha基于tensorrt+cuda c++实现模型end2end的gpu加速,支持win10.linux,在2023年已经更 ...