Mem468

DIV2

250的题过以前难了一点点,submit的很顺利,500的题很长,看了半天,没看懂,再者,见到那字符串就没啥胃口了,看1000的题,想了想,有了思路,但不确定是否可以,那个时候还40来分钟吧,然后就悲剧了,写的很搓,手慢。到Challenge结束后,才写完并Debug完,看DIV2中过的人,也是那样类似哈密顿DP的方法过的。

大意:有张图,记顶点1...n,A,B,要让A尽可能经过1..n中的点,然后到达B,但从Xi到Xj的费用是map[i][j] * (1 + cnt()),cnt()表示之前已经经过1..n中的点的数目,然后从这个过程有一个时间限制T。

然后就先建图,这里把我的精神写搓掉了,然后DP[i][j],i表示状态,j表示最后停在j点处的时间,要让这个尽可能小,最后就是DP[i][j],然后枚举状态i,找出到达B处的,时间在要求内,并且点数最多即可。

这些都是基于点数较少,可能枚举出所有的情况,这样想,跟哈密顿DP法就如出一辙了。

注意longlong以及dp[i][j]==-1的要continue掉,路径的费用要算对。

 

1 #include <iostream>
2 #include <string>
3 #include <algorithm>
4 #include <string.h>
5 #include <vector>
6 #include <math.h>
7 #include <time.h>
8 #include <queue>
9 #include <set>
10  using namespace std;
11
12 const long long MAX = 55;
13 const long long INF = 1000000001;
14
15 struct NODE
16 {
17 long long x, y;
18 long long t;
19 NODE() {}
20 NODE(long long xx, long long yy, long long tt) : x(xx), y(yy), t(tt) {}
21 };
22
23 long long map[MAX][MAX];//distance
24 long long vetex[MAX][MAX];//flag
25 long long nodeCnt;
26 long long n;
27 long long citySizeX;
28 long long citySizeY;
29 long long move[4][2] = {-1, 0, 0, 1, 1, 0, 0, -1};
30 long long path[1 << 16][20];
31
32 long long dp[1 << 16][20];
33
34 bool check(long long x, long long y)
35 {
36 if(x < 0 || y < 0 || x >= citySizeX || y >= citySizeY) return false;
37 if(vetex[x][y] == -1) return false;
38 return true;
39 }
40
41 long long oneCnt(long long x)
42 {
43 long long res = 0;
44 while(x)
45 {
46 if(x & 1) res++;
47 x >>= 1;
48 }
49 return res;
50 }
51
52 void bfs(long long x, long long y, long long ss)
53 {
54 vector<NODE>q;
55 long long s[MAX][MAX];
56 memset(s, 0, sizeof(s));
57 s[x][y] = 1;
58 q.push_back(NODE(x, y, 0));
59 for(long long i = 0; i < q.size(); i++)
60 {
61 for(long long j = 0; j < 4; j++)
62 {
63 long long xx = q[i].x + move[j][0];
64 long long yy = q[i].y + move[j][1];
65 if(check(xx, yy) && s[xx][yy] == 0)
66 {
67 s[xx][yy] = 1;
68 if(vetex[xx][yy] > 0) map[ss][vetex[xx][yy]] = q[i].t + 1;
69 q.push_back(NODE(xx, yy, q[i].t + 1));
70 }
71 }
72 }
73 }
74
75 void show(long long i)
76 {
77 while(i)
78 {
79 printf("%d", i & 1);
80 i >>= 1;
81 }
82 printf("\n");
83 }
84
85 void dfs(long long i, long long j)
86 {
87 while(1)
88 {
89 printf("#%d\n", j + 1);
90 if(path[i][j] == -1) break;
91 long long t = path[i][j];
92 i = t / 100;
93 j = t % 100;
94
95 }
96
97 for(i = 1; i <= nodeCnt; i++)
98 {
99 for(long long j = 1; j <= nodeCnt; j++)
100 {
101 printf("%d ", map[i][j]);
102 }
103 printf("\n");
104 }
105 }
106
107 long long go(vector <string> city, long long T)
108 {
109 nodeCnt = 0;
110 citySizeX = city.size();
111 citySizeY = city[0].size();
112 long long i, j;
113 long long ki, kj, qi, qj;
114 for(long long i = 0; i < city.size(); i++)
115 {
116 for(long long j = 0; j < city[i].size(); j++)
117 {
118 if(city[i][j] == '.') vetex[i][j] = 0;
119 else if(city[i][j] == '#') vetex[i][j] = -1;
120 else if(city[i][j] == 'K')
121 {
122 ki = i, kj = j;
123 }
124 else if(city[i][j] == 'Q') qi = i, qj = j;
125 else if(city[i][j] == 'G') vetex[i][j] = ++nodeCnt;
126 }
127 }
128 vetex[ki][kj] = ++nodeCnt;
129 vetex[qi][qj] = ++nodeCnt;
130 n = nodeCnt - 2;
131
132 //get distance
133 for(long long i = 1; i <= nodeCnt; i++)
134 {
135 for(long long j = 1; j <= nodeCnt; j++)
136 {
137 if(i == j) map[i][j] = 0;
138 else map[i][j] = INF;
139 }
140 }
141 for(long long i = 0; i < city.size(); i++)
142 {
143 for(long long j = 0; j < city[i].size(); j++)
144 {
145 if(vetex[i][j] > 0) bfs(i, j, vetex[i][j]);
146 }
147 }
148
149 memset(dp, -1, sizeof(dp));
150 memset(path, -1, sizeof(path));
151 for(long long i = 0; i < n; i++)
152 {
153 dp[1 << i][i] = map[n + 1][i + 1];
154 }
155 for(long long i = 0; i < (1 << n); i++)
156 {
157 for(long long j = 0; j < n; j++)
158 {
159 if((1 << j) & i)
160 {
161 if(dp[i][j] == -1) continue;
162 for(long long kk = 0; kk < n; kk++)
163 {
164 if(kk == j) continue;
165 if((1 << kk) & i) continue;
166 if(map[j + 1][kk + 1] == INF) continue;
167 long long num = oneCnt(i);
168 if(dp[i + (1 << kk)][kk] == -1 || dp[i][j] + map[j + 1][kk + 1] * (1 + num) < dp[i + (1 << kk)][kk])
169 {
170 dp[i + (1 << kk)][kk] = dp[i][j] + map[j + 1][kk + 1] * (1 + num);
171 path[i + (1 << kk)][kk] = i * 100 + j;
172 }
173 }
174 }
175 }
176 }
177
178 long long ans = 0;
179 for(long long i = 0; i < (1 << n); i++)
180 {
181 for(long long j = 0; j < n; j++)
182 {
183 if((1 << j) & i)
184 {
185 if(dp[i][j] == -1) continue;
186 if(dp[i][j] + map[j + 1][n + 2] * (1 + oneCnt(i)) <= T)
187 {
188 if(oneCnt(i) > ans)
189 {
190 ans = oneCnt(i);
191 if(ans == 4)
192 {
193 show(i);
194 dfs(i, j);
195 }
196 }
197 }
198 }
199 }
200 }
201 return ans;
202 }
203
204 class Gifts
205 {
206 public:
207 int maxGifts(vector <string> city, int T)
208 {
209 return go(city, T);
210 }
211 };

 

转载于:https://www.cnblogs.com/litstrong/archive/2010/04/20/1716545.html

In file included from cryptlib.c:117:0: cryptlib.h:62:21: fatal error: stdlib.h: No such file or directory # include <stdlib.h> ^ compilation terminated. mem.c:59:19: fatal error: stdio.h: No such file or directory #include <stdio.h> ^ compilation terminated. mem_clr.c:60:20: fatal error: string.h: No such file or directory #include <string.h> ^ compilation terminated. mem_dbg.c:112:19: fatal error: stdio.h: No such file or directory #include <stdio.h> ^ compilation terminated. In file included from cversion.c:59:0: cryptlib.h:62:21: fatal error: stdlib.h: No such file or directory # include <stdlib.h> ^ compilation terminated. In file included from ex_data.c:141:0: cryptlib.h:62:21: fatal error: stdlib.h: No such file or directory # include <stdlib.h> ^ compilation terminated. cpt_err.c:62:19: fatal error: stdio.h: No such file or directory #include <stdio.h> ^ compilation terminated. In file included from uid.c:56:0: ../include/openssl/crypto.h:120:21: fatal error: stdlib.h: No such file or directory # include <stdlib.h> ^ compilation terminated. o_time.c:65:20: fatal error: string.h: No such file or directory #include <string.h> ^ compilation terminated. o_str.c:60:19: fatal error: ctype.h: No such file or directory #include <ctype.h> ^ compilation terminated. o_dir.c:60:19: fatal error: errno.h: No such file or directory #include <errno.h> ^ compilation terminated. In file included from o_fips.c:59:0: cryptlib.h:62:21: fatal error: stdlib.h: No such file or directory # include <stdlib.h> ^ compilation terminated. In file included from o_init.c:56:0: ../e_os.h:468:28: fatal error: unistd.h: No such file or directory # include OPENSSL_UNISTD ^ compilation terminated. getenv.c:14:20: fatal error: stdlib.h: No such file or directory #include <stdlib.h> ^ compilation terminated. Makefile:138: recipe for target 'local_depend' failed make[1]: *** [local_depend] Error 1 make[1]: Leaving directory '/home/holand/work/openssl-OpenSSL_1_0_2u/crypto' Makefile:483: recipe for target 'depend' failed make: *** [depend] Error 1
06-13
JFM7VX690T型SRAM型现场可编程门阵列技术手册主要介绍的是上海复旦微电子集团股份有限公司(简称复旦微电子)生产的高性能FPGA产品JFM7VX690T。该产品属于JFM7系列,具有现场可编程特性,集成了功能强大且可以灵活配置组合的可编程资源,适用于实现多种功能,如输入输出接口、通用数字逻辑、存储器、数字信号处理和时钟管理等。JFM7VX690T型FPGA适用于复杂、高速的数字逻辑电路,广泛应用于通讯、信息处理、工业控制、数据中心、仪表测量、医疗仪器、人工智能、自动驾驶等领域。 产品特点包括: 1. 可配置逻辑资源(CLB),使用LUT6结构。 2. 包含CLB模块,可用于实现常规数字逻辑和分布式RAM。 3. 含有I/O、BlockRAM、DSP、MMCM、GTH等可编程模块。 4. 提供不同的封装规格和工作温度范围的产品,便于满足不同的使用环境。 JFM7VX690T产品系列中,有多种型号可供选择。例如: - JFM7VX690T80采用FCBGA1927封装,尺寸为45x45mm,使用锡银焊球,工作温度范围为-40°C到+100°C。 - JFM7VX690T80-AS同样采用FCBGA1927封装,但工作温度范围更广,为-55°C到+125°C,同样使用锡银焊球。 - JFM7VX690T80-N采用FCBGA1927封装和铅锡焊球,工作温度范围与JFM7VX690T80-AS相同。 - JFM7VX690T36的封装规格为FCBGA1761,尺寸为42.5x42.5mm,使用锡银焊球,工作温度范围为-40°C到+100°C。 - JFM7VX690T36-AS使用锡银焊球,工作温度范围为-55°C到+125°C。 - JFM7VX690T36-N使用铅锡焊球,工作温度范围与JFM7VX690T36-AS相同。 技术手册中还包含了一系列详细的技术参数,包括极限参数、推荐工作条件、电特性参数、ESD等级、MSL等级、重量等。在产品参数章节中,还特别强调了封装类型,包括外形图和尺寸、引出端定义等。引出端定义是指对FPGA芯片上的各个引脚的功能和接线规则进行说明,这对于FPGA的正确应用和电路设计至关重要。 应用指南章节涉及了FPGA在不同应用场景下的推荐使用方法。其中差异说明部分可能涉及产品之间的性能差异;关键性能对比可能包括功耗与速度对比、上电浪涌电流测试情况说明、GTH Channel Loss性能差异说明、GTH电源性能差异说明等。此外,手册可能还提供了其他推荐应用方案,例如不使用的BANK接法推荐、CCLK信号PCB布线推荐、JTAG级联PCB布线推荐、系统工作的复位方案推荐等,这些内容对于提高系统性能和稳定性有着重要作用。 焊接及注意事项章节则针对产品的焊接过程提供了指导,强调焊接过程中的注意事项,以确保产品在组装过程中的稳定性和可靠性。手册还明确指出,未经复旦微电子的许可,不得翻印或者复制全部或部分本资料的内容,且不承担采购方选择与使用本文描述的产品和服务的责任。 上海复旦微电子集团股份有限公司拥有相关的商标和知识产权。该公司在中国发布的技术手册,版权为上海复旦微电子集团股份有限公司所有,未经许可不得进行复制或传播。 技术手册提供了上海复旦微电子集团股份有限公司销售及服务网点的信息,方便用户在需要时能够联系到相应的服务机构,获取最新信息和必要的支持。同时,用户可以访问复旦微电子的官方网站(***以获取更多产品信息和公司动态。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值