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


第一题:模拟。。

第二题:水题

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

/*
* Problem: C. Sereja and Prefixes
* Author: Shun Yao
*/ #include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <assert.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <time.h> #include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <bitset>
#include <utility>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> //using namespace std; int m, n, a[100010], b[100010], c[100010], e[100010];
long long d[100010]; int main(/*int argc, char **argv*/) {
int i, j, k;
long long len; scanf("%d", &m);
for (i = 1; i <= m; ++i) {
scanf("%d", &a[i]);
if (a[i] == 1)
scanf("%d", &b[i]);
else
scanf("%d %d", &b[i], &c[i]);
}
scanf("%d", &n);
for (i = 1; i <= n; ++i)
scanf("%I64d", &d[i]);
j = 1;
len = 0;
for (i = 1; i <= m; ++i) {
if (a[i] == 1) {
++len;
if (len <= 100000)
e[len] = b[i];
while (j <= n && d[j] == len) {
++j;
printf("%d ", b[i]);
}
} else {
if (len < 100000) {
for (k = len + 1; k <= 100000 && k <= len + b[i] * c[i]; ++k)
e[k] = e[(k - len) % b[i] == 0 ? b[i] : (k - len) % b[i]];
}
while (j <= n && d[j] <= len + b[i] * c[i]) {
printf("%d ", e[(d[j] - len) % b[i] == 0 ? b[i] : (d[j] - len) % b[i]]);
++j;
}
len += b[i] * c[i];
}
} fclose(stdin);
fclose(stdout);
return 0;
}

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

/*
* Problem: Sereja and Tree
* Author: Shun Yao
*/ #include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <assert.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <time.h> #include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <bitset>
#include <utility>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> //using namespace std; int n, m, z[7010];
int u;
std::map<int, int> rn;
class Data {
public:
int first, second, third;
Data() {}
Data(int f, int s, int t) : first(f), second(s), third(t) {}
} ;
std::vector<Data> g[7010]; int main(/*int argc, char **argv*/) {
int i, t, l, r, x; // freopen("D.in", "r", stdin);
// freopen("D.out", "w", stdout); scanf("%d%d", &n, &m);
u = 0;
for (i = 1; i <= m; ++i) {
scanf("%d", &t);
if (t == 1) {
scanf("%d%d%d%d", &t, &l, &r, &x);
g[t].push_back(Data(l, r, rn.count(x) ? rn[x] : rn[x] = u++));
} else {
scanf("%d%d", &t, &l);
for (r = l; t <= n; ++t) {
for (x = 0; x < static_cast<int>(g[t].size()); ++x)
if (std::max(g[t][x].first, l) <= std::min(g[t][x].second, r))
z[g[t][x].third] = i;
if (l > 1)
l += 32 - __builtin_clz(l - 1);
r += 32 - __builtin_clz(r);
}
x = 0;
for (t = 0; t < u; ++t)
x += z[t] == i;
printf("%d\n", x);
}
} fclose(stdin);
fclose(stdout);
return 0;
}

第五题:

  官方题解给的是线段树。

  我用树状数组离线搞的。

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. C++:对象的初始化和构造函数

    对象的初始化和构造函数 构造函数:是一种特殊的成员函数,它主要用于为对象分配空间,进行初始化.构造函数 的名字必须与类名相同,它不要用户来调用,而是在建立对象时自动执行的 形式一: 类名 对象名(实参 ...

  2. java.lang.NumberFormatException: For input string:"filesId"

    做项目时候,页面获取出现了这个问题.找了好久一直以为是我字段或者是数据库字段问题导致引起的. 最后才发现是 struts2中jsp我写错了一个参数,一直导致报错.后来改了就好了. 当大家遇到这个问题的 ...

  3. Android权限安全(9)Android权限特点及权限管理服务AppOps Service

    Android权限特点 权限管理服务AppOps Service 图中元素介绍: Ignore 是不提示的,Allow 是允许,Reject 是拒绝 Client是一个使用sms 的应用, AppOp ...

  4. [IE编程] 多页面基于IE内核浏览器的代码示例

    有不少人发信问这个问题,我把答案贴在这里: 建议参考 WTL (Windows Template Library) 的代码示例工程TabBrowser  (在WTL目录/Samples/TabBrow ...

  5. 关于BigDecimal的四舍五入和截断 (2007-08-10 15:06:26)

    关于四舍五入:ROUND_HALF_UP: 遇到.5的情况时往上近似,例: 1.5 ->;2ROUND_HALF_DOWN : 遇到.5的情况时往下近似,例: 1.5 ->;1 BigDe ...

  6. The secret code

    The secret code Input file: stdinOutput file: stTime limit: 1 sec Memory limit: 256 MbAfter returnin ...

  7. crontab无法调用java的问题解决

    本来想将写的代码挂在crontab下运行,谁知道无法运行,没有任何输出,试着用ls -al >> 1.log试了一下,确定crontab是正常运行的. 从网站上找了下问题,原因出在cron ...

  8. UVa 1648 (推公式) Business Center

    题意: 有一种奇怪的电梯,每次只能向上走u个楼层或者向下走d个楼层 现在有m个这种电梯,求恰好n次能够到达的最小楼层数(必须是正数),最开始默认位于第0层. 分析: 假设电梯向上走x次,则向下走n-x ...

  9. WEB前端开发成长指南

    小 编注:相比起网页射击狮,操纵代码的前端攻城狮凭着双手在键盘巴拉巴拉敲出的字符,就能赋予二次元的静态页面生命,各种lovely 的~~fabulous的~~elegant的交互效果,那叫一个锦上添花 ...

  10. 生产者和消费者(.net实现)

    生产者和消费者,是多线程中的经典问题,听过java方面的这个问题的培训,闲暇时用.net实现了这 个问题.在此实现的是,生产一个消息后,消费一个消息,再生产一个消息,循环往复.  1.消息代码  us ...