做的太糟糕了。。。第一题看成两人都取最优策略,写了个n^2的dp,还好pre-test良心(感觉TC和CF的pretest还是很靠谱的),让我反复过不去,仔细看题原来是取两边最大的啊!!!前30分钟就这样度过了。。。题目的分数啊刷刷掉啊( ˙灬˙ )。用了8分钟搞完第二题,然后第三题。第五题在1:20左右的时候开始写一个树状数组,1:29的时候写完了,结果样例不过,仔细看看居然是树状数组修改时从1开始修改的,无语啊。于是就。。。。。。只做上了3道题,被虐的好惨啊。。。


第一题:模拟。。

第二题:水题

第三题:暴力到100000(l[i]的最大值)

  1. /*
  2. * Problem: C. Sereja and Prefixes
  3. * Author: Shun Yao
  4. */
  5.  
  6. #include <string.h>
  7. #include <stdlib.h>
  8. #include <limits.h>
  9. #include <assert.h>
  10. #include <stdio.h>
  11. #include <ctype.h>
  12. #include <math.h>
  13. #include <time.h>
  14.  
  15. #include <map>
  16. #include <set>
  17. #include <list>
  18. #include <stack>
  19. #include <queue>
  20. #include <deque>
  21. #include <string>
  22. #include <vector>
  23. #include <bitset>
  24. #include <utility>
  25. #include <iomanip>
  26. #include <numeric>
  27. #include <sstream>
  28. #include <iostream>
  29. #include <algorithm>
  30. #include <functional>
  31.  
  32. //using namespace std;
  33.  
  34. int m, n, a[100010], b[100010], c[100010], e[100010];
  35. long long d[100010];
  36.  
  37. int main(/*int argc, char **argv*/) {
  38. int i, j, k;
  39. long long len;
  40.  
  41. scanf("%d", &m);
  42. for (i = 1; i <= m; ++i) {
  43. scanf("%d", &a[i]);
  44. if (a[i] == 1)
  45. scanf("%d", &b[i]);
  46. else
  47. scanf("%d %d", &b[i], &c[i]);
  48. }
  49. scanf("%d", &n);
  50. for (i = 1; i <= n; ++i)
  51. scanf("%I64d", &d[i]);
  52. j = 1;
  53. len = 0;
  54. for (i = 1; i <= m; ++i) {
  55. if (a[i] == 1) {
  56. ++len;
  57. if (len <= 100000)
  58. e[len] = b[i];
  59. while (j <= n && d[j] == len) {
  60. ++j;
  61. printf("%d ", b[i]);
  62. }
  63. } else {
  64. if (len < 100000) {
  65. for (k = len + 1; k <= 100000 && k <= len + b[i] * c[i]; ++k)
  66. e[k] = e[(k - len) % b[i] == 0 ? b[i] : (k - len) % b[i]];
  67. }
  68. while (j <= n && d[j] <= len + b[i] * c[i]) {
  69. printf("%d ", e[(d[j] - len) % b[i] == 0 ? b[i] : (d[j] - len) % b[i]]);
  70. ++j;
  71. }
  72. len += b[i] * c[i];
  73. }
  74. }
  75.  
  76. fclose(stdin);
  77. fclose(stdout);
  78. return 0;
  79. }

第四题:分层记录线段(即l,r,x),依次查询每层,记录出现过的颜色。(不用__builtin_clz会tle的。。)

  1. /*
  2. * Problem: Sereja and Tree
  3. * Author: Shun Yao
  4. */
  5.  
  6. #include <string.h>
  7. #include <stdlib.h>
  8. #include <limits.h>
  9. #include <assert.h>
  10. #include <stdio.h>
  11. #include <ctype.h>
  12. #include <math.h>
  13. #include <time.h>
  14.  
  15. #include <map>
  16. #include <set>
  17. #include <list>
  18. #include <stack>
  19. #include <queue>
  20. #include <deque>
  21. #include <string>
  22. #include <vector>
  23. #include <bitset>
  24. #include <utility>
  25. #include <iomanip>
  26. #include <numeric>
  27. #include <sstream>
  28. #include <iostream>
  29. #include <algorithm>
  30. #include <functional>
  31.  
  32. //using namespace std;
  33.  
  34. int n, m, z[7010];
  35. int u;
  36. std::map<int, int> rn;
  37. class Data {
  38. public:
  39. int first, second, third;
  40. Data() {}
  41. Data(int f, int s, int t) : first(f), second(s), third(t) {}
  42. } ;
  43. std::vector<Data> g[7010];
  44.  
  45. int main(/*int argc, char **argv*/) {
  46. int i, t, l, r, x;
  47.  
  48. // freopen("D.in", "r", stdin);
  49. // freopen("D.out", "w", stdout);
  50.  
  51. scanf("%d%d", &n, &m);
  52. u = 0;
  53. for (i = 1; i <= m; ++i) {
  54. scanf("%d", &t);
  55. if (t == 1) {
  56. scanf("%d%d%d%d", &t, &l, &r, &x);
  57. g[t].push_back(Data(l, r, rn.count(x) ? rn[x] : rn[x] = u++));
  58. } else {
  59. scanf("%d%d", &t, &l);
  60. for (r = l; t <= n; ++t) {
  61. for (x = 0; x < static_cast<int>(g[t].size()); ++x)
  62. if (std::max(g[t][x].first, l) <= std::min(g[t][x].second, r))
  63. z[g[t][x].third] = i;
  64. if (l > 1)
  65. l += 32 - __builtin_clz(l - 1);
  66. r += 32 - __builtin_clz(r);
  67. }
  68. x = 0;
  69. for (t = 0; t < u; ++t)
  70. x += z[t] == i;
  71. printf("%d\n", x);
  72. }
  73. }
  74.  
  75. fclose(stdin);
  76. fclose(stdout);
  77. return 0;
  78. }

第五题:

  官方题解给的是线段树。

  我用树状数组离线搞的。

Codeforces 381 简要题解的更多相关文章

  1. Codeforces 863 简要题解

    文章目录 A题 B题 C题 D题 E题 F题 G题 传送门 简要题解?因为最后一题太毒不想写了所以其实是部分题解... A题 传送门 题意简述:给你一个数,问你能不能通过加前导000使其成为一个回文数 ...

  2. Codeforces 1120 简要题解

    文章目录 A题 B题 C题 D题 E题 F题 传送门 A题 传送门 题意简述:给你一个mmm个数的数列,现在规定把一个数列的1,2,...,k1,2,...,k1,2,...,k分成第一组,把k+1, ...

  3. Codeforces 1098 简要题解

    文章目录 前言 A题 B题 C题 D题 E题 传送门 前言 没错因为蒟蒻太菜了这场的最后一道题也咕掉了,只有AAA至EEE的题解233 A题 传送门 题意简述:给出一棵带点权的树,根节点深度为111, ...

  4. Codeforces 1110 简要题解

    文章目录 A题 B题 C题 D题 E题 F题 G题 传送门 众所周知ldxoildxoildxoi这种菜鸡选手是不会写HHH题的,因此该篇博客只有AAA题至GGG题的题解,实在抱歉. A题 传送门 题 ...

  5. Codeforces 380 简要题解

    ABC见上一篇. 感觉这场比赛很有数学气息. D: 显然必须要贴着之前的人坐下. 首先考虑没有限制的方案数.就是2n - 1(我们把1固定,其他的都只有两种方案,放完后长度为n) 我们发现对于一个限制 ...

  6. Codeforces 845 简要题解

    文章目录 A题 B题 C题 D题 E题 F题 G题 传送门 A题 传送门 题意:2n2n2n个人下棋,分为两个阵营,每个阵营nnn个人,每个人有一个积分,积分高的能赢积分低的,问如果你可以随意选人,然 ...

  7. Codeforces 1065 简要题解

    文章目录 A题 B题 C题 D题 E题 F题 G题 传送门 GGG题略难,膜了一波zhouyuyang{\color{red} zhouyuyang}zhouyuyang巨佬的代码. 其余都挺清真的. ...

  8. Codeforces 888 简要题解

    文章目录 A题 B题 C题 D题 E题 F题 G题 传送门 A题 传送门 题意简述:给一个数列,问有多少个峰值点(同时比两边都大/小的点) 思路:按照题意模拟. 代码: #include<bit ...

  9. Codeforces 884 简要题解

    文章目录 A题 B题 C题 D题 E题 F题 传送门 A题 传送门 题意简述: 一个人要完成一件事总共需要ttt秒,现在有nnn天,每天有aia_iai​不能做事,问他可以在第几天做完. 思路:按照题 ...

随机推荐

  1. Python数字加千分符

    1.最简单的内置format函数: >>> format(1234567890,',') '1,234,567,890' 2.正则表达式: import re def formatN ...

  2. JS代码片段:判断一个元素是否进入可视区域

    // Determine if an element is in the visible viewport function isInViewport(element) { var rect = el ...

  3. ios开发之 MPMoviePlayerController 视频播放器

    MPMoviePlayerController 与AVAudioPlayer有点类似,前者播放视频,后者播放音频,不过也有很大不同,MPMoviePlayerController 可以直接通过远程UR ...

  4. Linux命令之chmod 及+s 参数(临时以所有者权限执行)

    转自: http://blog.csdn.net/shaobingj126/article/details/7031221 chmod用于改变文件或目录的访问权限.用户用它控制文件或目录的访问权限.该 ...

  5. npm在项目目录安装插件需要使用sudo

    今天使用node的npm安装插件的时候遇到一个问题,那就是在项目目录里面安装插件的时候,必须使用超级用户(sudo)执行才会安装成功,否则会报如下错误: 以安装 gulp-uglify 为例 $ np ...

  6. perl基本语法

    标量 标量是 Perl 中最简单的数据类型.大多数的标量是数字(如 255 或 3.25e20)或者字符串(如 hello或者盖茨堡地址). 数字 perl中所有数字内部的格式都是双精度浮点数. 浮点 ...

  7. sdut 2831 Euclid (几何)

    题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2831 题意:给a, b,  c,  d, ...

  8. 函数fil_io

    /********************************************************************//** Reads or writes data. This ...

  9. bzoj2436

    不难发现两边的活动是交替进行的,我们可以dp 先对时间离散化,设f[i,j]到时间i一个会场选j个活动,另一个会场最多有多少活动,那么f[i,j]=max(f[k,j]+s[k,i],f[k,j-s[ ...

  10. Asp.Net Unix时间戳和DateTime类型转换

    using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System. ...