Problem Id Title
1141 Problem A 六神无主
1142 Problem B 追踪器
1143 Problem C Game
1144 Problem D 计算罚时
1145 Problem E 超级整除2
1146 Problem F 3xian的抽象画

题目比较水,除了最后一个题,都不发代码了

PRO A:  直接模拟除法

PRO B:  直接比较,输出答案

PRO C:SRM DIV1 470 1000P的原题,求一个最大生成树的总权值

PRO D:  模拟,不过要按照时间拍下序,用两个MAP来记录

PRO E: 鸽巢原理

PRO F:

此题是很好的一道题, 首先要维护一个栈,来维护这个序列,每当遇到'(' 进栈,遇到')'出栈,那么这个括号序列就是个欧拉序列了~,根据这个欧拉序列建一个树,而且还要记录树的高度,每个节点的高度 = max( 儿子节点的高度 ) + 1。 这个时候若父节点被覆盖,则子节点不用被覆盖,若子节点没覆盖,则孙子节点要覆盖,就这样,最大需要覆盖的面积为第一个父节点的(右值 - 左值) * 高度,不需要覆盖的就为子节点的面积,这样算下去,用一个BFS每层处理很方便,代码有点猥琐,凑合着看,由于int错了一次,于是一次性全部把int 换成 LL。

代码

1 #include <iostream>
2 #include <stack>
3
4  using namespace std;
5
6  const int maxn = 400009;
7
8 typedef __int64 LL;
9
10 struct node {
11 LL v;
12 node* next;
13 } *adj[maxn], edge[maxn];
14
15 struct tree {
16 LL l, r, cnt, high, f;
17 } tt[maxn] ;
18
19 LL e_num, tot, len;
20 char in[maxn];
21
22 void add_edge(LL u, LL v)
23 {
24 node* ptr = &edge[ e_num ++ ];
25 ptr -> v = v;
26 ptr -> next = adj[u];
27 adj[u] = ptr;
28 }
29
30 void init()
31 {
32 e_num = tot = 0;
33 for(LL i=0; i < maxn; i++) {
34 tt[i].high = 0;
35 adj[i] = NULL;
36 }
37 }
38
39 stack<LL> s;
40 void built()
41 {
42 LL father = 0;
43 for(LL i=0; i < len; i++)
44 {
45 if(in[i] == '(') {
46 tot ++;
47 tt[ tot ].l = i;
48 tt[ tot ].f = father;
49 add_edge(father , tot);
50 father = tot;
51 s.push( tot );
52 } else {
53 LL now = s.top(); s.pop();
54 tt[ now ].r = i;
55 for(node* ptr = adj[ now ]; ptr; ptr = ptr -> next)
56 tt[ now ].high = max( tt[ now ].high , tt[ ptr -> v ].high );
57 tt[now].high ++;
58 father = tt[ now ].f;
59 }
60 }
61 }
62
63 struct xiaowu { LL cnt, u; } que[maxn], tmp, nxt;
64
65 LL bfs(LL now)
66 {
67 LL head = 0 , tail = 0;
68 LL area = (tt[now].r - tt[now].l) * tt[now].high;
69
70 tmp.cnt = 1;
71 tmp.u = now;
72
73 que[tail ++] = tmp;
74
75
76 while(head != tail)
77 {
78 tmp = que[head ++]; head %= maxn;
79
80 for(node* ptr = adj[tmp.u]; ptr; ptr = ptr -> next)
81 {
82 LL v = ptr -> v;
83 if(tmp.cnt == 1)
84 area -= tt[ v ].high * ( tt[ v ].r - tt[ v ].l ) ;
85 else
86 area += tt[ v ].high * ( tt[ v ].r - tt[ v ].l ) ;

89 nxt.u = v;
90 nxt.cnt = tmp.cnt * -1;
91 que[tail ++] = nxt;
92 tail %= maxn;
93 }
94 }
95
96 return area;
97 }
98
99 LL solve()
100 {
101 LL area = 0;
102 for(node* ptr = adj[0]; ptr ; ptr = ptr -> next)
103 {
104 LL son = ptr -> v;
105 area += bfs( son );
106 }
107 return area;
108 }
109
110 int main()
111 {
112 //freopen("in.in", "r", stdin);
113 int cas;
114 cin >> cas;
115 while(cas --)
116 {
117 init();
118 cin >> in;
119 len = strlen( in );
120 built();
121 printf("%I64d\n", solve());
122 }
123 return 0;
124 }
125

转载于:https://www.cnblogs.com/xiao_wu/archive/2010/05/30/1747735.html

GDUT Monthly相关推荐

  1. 二分搜索 POJ 3273 Monthly Expense

    题目传送门 1 /* 2 题意:分成m个集合,使最大的集合值(求和)最小 3 二分搜索:二分集合大小,判断能否有m个集合. 4 */ 5 #include <cstdio> 6 #incl ...

  2. 【POJ 3273】 Monthly Expense (二分)

    [POJ 3273] Monthly Expense (二分) 一个农民有块地 他列了个计划表 每天要花多少钱管理 但他想用m个月来管理 就想把这个计划表切割成m个月来完毕 想知道每一个月最少花费多少 ...

  3. 思维+multiset ZOJ Monthly, July 2015 - H Twelves Monkeys

    题目传送门 1 /* 2 题意:n个时刻点,m次时光穿梭,告诉的起点和终点,q次询问,每次询问t时刻t之前有多少时刻点是可以通过两种不同的路径到达 3 思维:对于当前p时间,从现在到未来穿越到过去的是 ...

  4. Monthly Expense POJ - 3273(二分最大值最小化)

    Farmer John is an astounding accounting wizard and has realized he might run out of money to run the ...

  5. 洛谷P2884 [USACO07MAR]Monthly Expense S

    题目描述 Farmer John is an astounding accounting wizard and has realized he might run out of money to ru ...

  6. EOJ Monthly 2019.11 E. 数学题(反演 + 杜教筛 + 拉格朗日插值)

    EOJ Monthly 2019.11 ∑i=1n∑a1=1i∑a2=1i∑a3=1i⋯∑ak−1i∑aki[gcd(a1,a2,a3,-,ak−1,ak,i)==1]=∑i=1n∑d∣iμ(d)⌊i ...

  7. 【POJ - 3273 】Monthly Expense (二分,最小最大值)

    题干: Farmer John is an astounding accounting wizard and has realized he might run out of money to run ...

  8. Monthly Expense【二分】

    B - Monthly Expense POJ - 3273 Farmer John is an astounding accounting wizard and has realized he mi ...

  9. Monthly Expense( POJ-3273 )

    Problem Description Farmer John is an astounding accounting wizard and has realized he might run out ...

最新文章

  1. linux查看占用端口号的程序及pid
  2. UI:UITableView表视图
  3. Linux下sed命令替换配置文件中某个变量的值(改变包含字符的一行的值)之二——只改变第一出现的那一行
  4. 凯立德地图导航2020年最新版车载_明明有车载导航,为什么很多人还是选择用手机导航?有5个原因...
  5. 前端又要失失失失失失失失失业了!
  6. 史上最经典CAP讲解
  7. Learning Shape Priors for Single-View 3D Completion and Reconstruction
  8. spring事务管理几种方式(转)
  9. c语言怎样存放学生信息,C语言共用体存放学生信息
  10. Java 开源Wiki:XWiki
  11. mysql sqlite 语法_浅谈sqlite与mysql的数据库语法差异_沃航科技
  12. 2018年 - 年终总结
  13. 21秋期末考试组织行为学10068k2
  14. [html] 微软雅黑是有版权的,在页面中使用font-family:Microsoft YaHei会不会有版权问题呢?
  15. C# 如何在Excel表格中插入、编辑和删除批注
  16. 李宏毅2020机器学习笔记2——CXK
  17. 超声波模块的原理介绍之时间函数和digitalRead函数的使用
  18. ABBYY最新OCR文字识别软件 ,需激活码序列号密钥安装下载
  19. 小程序云开发支持公众号网页开发了
  20. VSCode下载与安装使用教程【超详细讲解】

热门文章

  1. 左耳听风 第三十一周
  2. 数字电路设计之各种触发器的verilog实现
  3. 模型商业化时产权保护有何技术手段?protege 专为数据分析/机器学习建模而打造
  4. 2017全国大学生电子设计大赛B题 | 板球控制系统(四)机械设计相关
  5. 图像处理------>获取图像特征
  6. 项目实训-关键词提取-论文研读-load centrality的合理性探讨
  7. java-根据url生成二维码
  8. 松下FPXH自动螺丝机程序 昆仑通态触摸屏控触摸,松 下FPXH数据表定位模式,写法新颖
  9. PYTHON DJANGO开发工资查询系统
  10. CodeBlocks使用方法