P1072 Hankson 的趣味题

摘要: ``` include define inf 1000000000 define ll long long using namespace std; int read() { int x=0,f=1;char ch=getchar(); while(ch'9'){if(ch==' ')f= 1;ch 阅读全文
posted @ 2016-11-16 19:36 蒟蒻konjac 阅读(283) 评论(0) 推荐(0) 编辑

P1074 靶形数独 - 40

摘要: ``` include define searchnext(x, y) y == 9 ? search(x + 1, 1) : search(x, y + 1) using namespace std; long long ans = 0; int a[10][10]; void search(in 阅读全文
posted @ 2016-11-16 19:35 蒟蒻konjac 阅读(154) 评论(0) 推荐(0) 编辑

P1967 货车运输 -60分

摘要: 打了一个最大生成树+dfs,60分成功tle include using namespace std; const int maxn = 10005; const int maxm = 50005; int n, m, cnt = 0; struct edge { int from, to, val 阅读全文
posted @ 2016-11-15 15:45 蒟蒻konjac 阅读(143) 评论(0) 推荐(0) 编辑

P1941 飞扬的小鸟

摘要: 此题很容易写出方程,由以前的知识可以迁移得,本题可以用完全背包的方法进行优化,使用滚动数组即可得到答案。 //莫名奇妙60分。不知道什么细节出了错。 include using namespace std; const int maxn = 10005; int main() { // freope 阅读全文
posted @ 2016-11-15 11:06 蒟蒻konjac 阅读(156) 评论(0) 推荐(0) 编辑

P1026 统计单词个数

摘要: 题意 给出一段字符串和一个字典,把字符串划分为n个连续的子串,求一种最优的划分方式使字符串所含单词数最大。(详见NOIp2001) 思路 这个题是一个很典型的线性dp,难点主要在预处理上。 理解题意后,我们不难写出状态转移方程: f[i][j] = max(f[k][j 1] + calc(k+1, 阅读全文
posted @ 2016-11-15 06:28 蒟蒻konjac 阅读(177) 评论(0) 推荐(0) 编辑

P1073 最优贸易

摘要: ``` include using namespace std; const int maxn = 100005; int head1[maxn], head2[maxn], maxx[maxn], minn[maxn]; bool in1[maxn], in2[maxn]; int value[m 阅读全文
posted @ 2016-11-14 11:37 蒟蒻konjac 阅读(131) 评论(0) 推荐(1) 编辑

P1514 引水入城

摘要: 概述 首先,这是一道好题,这道题既考查了图论的dfs知识,又考察了区间贪心问题中很典型的区间覆盖问题,着实是一道好题。 大概思路说明 我们观察到,只有第一行可以放水库,而第一行在哪里放水库的结果就是直接导致最后一行某些点被覆盖。所以我们 只需要找到第一行水库与最后一行被覆盖的关系 即可完成决策,中间 阅读全文
posted @ 2016-11-14 09:28 蒟蒻konjac 阅读(193) 评论(0) 推荐(1) 编辑

P1311 选择客栈

摘要: 开始写了一个O(n3)的算法,只得了60,后来思考(找题解),得到了一个O(nk)的算法 其实就是一种预处理的思想,对于每一个客栈而言,只要我们预处理出他前面可以匹配的客栈数量,就可以了。 所以我们记录a[i]为颜色i的数量,b[i]为颜色i可匹配的数量 输入每一个客栈,我们都更新a[i],同时如果 阅读全文
posted @ 2016-11-13 18:43 蒟蒻konjac 阅读(181) 评论(0) 推荐(0) 编辑

P1038 神经网络

摘要: ``` include using namespace std; const int maxn = 105; struct node { int situation, yuzhi; }ns[maxn]; std::vector g[maxn]; int main() { int n, p; cin 阅读全文
posted @ 2016-11-13 15:43 蒟蒻konjac 阅读(183) 评论(0) 推荐(0) 编辑

P1079 Vigenère 密码

摘要: ``` include using namespace std; const int maxn = 1005; int main() { freopen("input.in", "r", stdin); char mi[maxn], key[105]; scanf("%s%s", key, mi); 阅读全文
posted @ 2016-11-13 09:12 蒟蒻konjac 阅读(183) 评论(0) 推荐(0) 编辑